diff options
author | Andres Rey <[email protected]> | 2018-09-02 20:51:42 +0100 |
---|---|---|
committer | Andres Rey <[email protected]> | 2018-09-02 20:51:42 +0100 |
commit | f2db151e599f699ee432fcadf4ae872426202dea (patch) | |
tree | 54aac9c4e88708a326c2d82898220a86393a52ee /src | |
parent | 18b61354ce2d0c2133b82b54254a9239ec5a5fe1 (diff) |
Add hasAttribute override
Diffstat (limited to 'src')
-rw-r--r-- | src/Nodes/DOM/DOMNode.php | 1 | ||||
-rw-r--r-- | src/Nodes/NodeTrait.php | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/Nodes/DOM/DOMNode.php b/src/Nodes/DOM/DOMNode.php index f1944c4..7c3c4f3 100644 --- a/src/Nodes/DOM/DOMNode.php +++ b/src/Nodes/DOM/DOMNode.php @@ -6,6 +6,7 @@ use andreskrey\Readability\Nodes\NodeTrait; /** * @method getAttribute($attribute) + * @method hasAttribute($attribute) */ class DOMNode extends \DOMNode { diff --git a/src/Nodes/NodeTrait.php b/src/Nodes/NodeTrait.php index 9f878ce..b4ca746 100644 --- a/src/Nodes/NodeTrait.php +++ b/src/Nodes/NodeTrait.php @@ -164,6 +164,24 @@ trait NodeTrait } /** + * Override for native hasAttribute + * + * @see getAttribute + * + * @param $attributeName + * + * @return bool + */ + public function hasAttribute($attributeName) + { + if (!is_null($this->attributes)) { + return parent::hasAttribute($attributeName); + } + + return false; + } + + /** * Get the ancestors of the current node. * * @param int|bool $maxLevel Max amount of ancestors to get. False for all of them |