protected function initialMatchOnClasses($selector, $matches)
{
$found = $this->newMatches();
$baseQuery = './/*[@class]';
$xpath = new \DOMXPath($this->dom);
// Now we try to find any matching IDs.
foreach ($matches as $node) {
// Refactor me!
if ($node->hasAttribute('class')) {
$intersect = array_intersect($selector->classes, explode(' ', $node->getAttribute('class')));
if (count($intersect) == count($selector->classes)) {
$found->attach($node);
}
}
$nl = $this->initialXpathQuery($xpath, $node, $baseQuery);
foreach ($nl as $node) {
$classes = $node->getAttribute('class');
$classArray = explode(' ', $classes);
$intersect = array_intersect($selector->classes, $classArray);
if (count($intersect) == count($selector->classes)) {
$found->attach($node);
}
}
}
// Unset the classes selector.
$selector->classes = array();
return $found;
}