summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndres Rey <[email protected]>2017-11-29 23:30:17 +0000
committerAndres Rey <[email protected]>2017-11-29 23:30:17 +0000
commitc0f0591b66eca9d9dc04985880755af55d6b6e2b (patch)
tree54fa70a59441f04ea249b78a69a16b68e86ea361 /src
parent632db7d1cd28e81e3ea9dff816d1f324ded27760 (diff)
Simplify getAttribute override
Diffstat (limited to 'src')
-rw-r--r--src/NodeClass/NodeClassTrait.php9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/NodeClass/NodeClassTrait.php b/src/NodeClass/NodeClassTrait.php
index 18782c6..f37c9fd 100644
--- a/src/NodeClass/NodeClassTrait.php
+++ b/src/NodeClass/NodeClassTrait.php
@@ -93,7 +93,8 @@ trait NodeClassTrait
}
/**
- * Placeholder for getAttribute method. Some nodes have the getAttribute method, some don't.
+ * Override for native getAttribute method. Some nodes have the getAttribute method, some don't, so we need
+ * to check first the existence of the attributes property.
*
* @param $attributeName string Attribute to retrieve
*
@@ -102,11 +103,7 @@ trait NodeClassTrait
public function getAttribute($attributeName)
{
if (!is_null($this->attributes)) {
- foreach ($this->attributes as $attribute) {
- if ($attribute->name === $attributeName) {
- return $attribute->value;
- }
- }
+ return parent::getAttribute($attributeName);
}
return '';