public function QueryPath::has in QueryPath 6
Same name and namespace in other branches
- 7.3 QueryPath/QueryPath.php \QueryPath::has()
- 7.2 QueryPath/QueryPath.php \QueryPath::has()
File
- QueryPath/
QueryPath.php, line 1614
Class
Code
public function has($contained) {
$found = new SplObjectStorage();
$nodes = array();
if (is_string($contained)) {
$nodes = $this
->branch($contained)
->get();
}
elseif ($contained instanceof DOMNode) {
$nodes = array(
$contained,
);
}
foreach ($nodes as $original_node) {
$node = $original_node;
while (!empty($node)) {
if ($this->matches
->contains($node)) {
$found
->attach($node);
}
$node = $node->parentNode;
}
}
$this
->setMatches($found);
return $this;
}