function PseudoSimple::check
Returns true if the selector part matches the given node, false otherwise
Parameters
Node $parent Parent node:
Return value
bool
Overrides Part::check
File
-
vendor/
mck89/ peast/ lib/ Peast/ Selector/ Node/ Part/ PseudoSimple.php, line 42
Class
- PseudoSimple
- Selector part simple pseudo class
Namespace
Peast\Selector\Node\PartCode
public function check(Node $node, $parent = null) {
switch ($this->name) {
case "pattern":
return $node instanceof Pattern;
case "statement":
return $node instanceof Statement;
case "expression":
return $node instanceof Expression;
case "declaration":
return $node instanceof Declaration;
case "last-child":
case "first-child":
$first = $this->name === "first-child";
$props = Utils::getExpandedNodeProperties($parent);
return count($props) > 0 && ($first ? $props[0] === $node : array_pop($props) === $node);
}
}