diff options
author | Andres Rey <[email protected]> | 2017-11-29 23:30:17 +0000 |
---|---|---|
committer | Andres Rey <[email protected]> | 2017-11-29 23:30:17 +0000 |
commit | c0f0591b66eca9d9dc04985880755af55d6b6e2b (patch) | |
tree | 54fa70a59441f04ea249b78a69a16b68e86ea361 | |
parent | 632db7d1cd28e81e3ea9dff816d1f324ded27760 (diff) |
Simplify getAttribute override
-rw-r--r-- | src/NodeClass/NodeClassTrait.php | 9 |
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 ''; |