Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
3 / 3 |
ElementNodeTrait | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
3 / 3 |
matchElementNode | |
100.00% |
1 / 1 |
2 | |
100.00% |
3 / 3 |
|||
match | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
<?php | |
namespace SDom\SelectorMatcher; | |
use SDom\Node\Element; | |
use Symfony\Component\CssSelector\Node\ElementNode; | |
use Symfony\Component\CssSelector\Node\NodeInterface; | |
/** | |
* @pattern * | |
* @meaning any element | |
* @link https://www.w3.org/TR/css3-selectors/#universal-selector | |
* | |
* @pattern E | |
* @meaning an element of type E | |
* @link https://www.w3.org/TR/css3-selectors/#type-selectors | |
* | |
* Trait ElementNodeTrait | |
* @package SDom\SelectorMatcher | |
*/ | |
trait ElementNodeTrait | |
{ | |
/** | |
* @param ElementNode $token | |
* @param Element $node | |
* @return bool | |
*/ | |
protected function matchElementNode(ElementNode $token, Element $node): bool | |
{ | |
// target element tag name may be null, directly return true as ElementNode tokens have no sub-selectors | |
if (null === $token->getElement()) { | |
return true; | |
} | |
// node tag name must match | |
return $node->getTag() === $token->getElement(); | |
} | |
/** | |
* @param NodeInterface $token | |
* @param Element $node | |
* @param Element|null $effectiveRoot | |
* @return bool | |
*/ | |
abstract public function match(NodeInterface $token, Element $node, Element $effectiveRoot = null): bool; | |
} |