@@ -7,11 +7,11 @@ discard block |
||
| 7 | 7 | namespace Transphporm\Pseudo; |
| 8 | 8 | class Not implements \Transphporm\Pseudo { |
| 9 | 9 | private $cssToXpath; |
| 10 | - private $config; |
|
| 10 | + private $config; |
|
| 11 | 11 | |
| 12 | 12 | public function __construct(\Transphporm\Parser\CssToXpath $cssToXpath, \Transphporm\Config $config) { |
| 13 | 13 | $this->cssToXpath = $cssToXpath; |
| 14 | - $this->config = $config; |
|
| 14 | + $this->config = $config; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | public function match($name, $args, \DomElement $element) { |
@@ -26,19 +26,19 @@ discard block |
||
| 26 | 26 | foreach ($css as $selector) { |
| 27 | 27 | $tokenizer = new \Transphporm\Parser\Tokenizer($selector); |
| 28 | 28 | $xpathString = $this->cssToXpath->getXpath($tokenizer->getTokens()); |
| 29 | - $pseudo = $this->cssToXpath->getPseudo($tokenizer->getTokens()); |
|
| 30 | - $pseudoMatcher = $this->config->createPseudoMatcher($pseudo); |
|
| 29 | + $pseudo = $this->cssToXpath->getPseudo($tokenizer->getTokens()); |
|
| 30 | + $pseudoMatcher = $this->config->createPseudoMatcher($pseudo); |
|
| 31 | 31 | if ($this->matches($xpath->query($xpathString), $element, $pseudoMatcher)) return false; |
| 32 | 32 | } |
| 33 | 33 | return true; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - private function matches($foundElements, $element, $pseudoMatcher) { |
|
| 37 | - //Find all nodes matched by the expressions in the brackets :not(EXPR) |
|
| 38 | - foreach ($foundElements as $matchedElement) { |
|
| 39 | - //Check to see whether this node was matched by the not query |
|
| 40 | - if ($pseudoMatcher->matches($matchedElement) && $element->isSameNode($matchedElement)) return true; |
|
| 41 | - } |
|
| 42 | - return false; |
|
| 43 | - } |
|
| 36 | + private function matches($foundElements, $element, $pseudoMatcher) { |
|
| 37 | + //Find all nodes matched by the expressions in the brackets :not(EXPR) |
|
| 38 | + foreach ($foundElements as $matchedElement) { |
|
| 39 | + //Check to see whether this node was matched by the not query |
|
| 40 | + if ($pseudoMatcher->matches($matchedElement) && $element->isSameNode($matchedElement)) return true; |
|
| 41 | + } |
|
| 42 | + return false; |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -15,7 +15,9 @@ discard block |
||
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | public function match($name, $args, \DomElement $element) { |
| 18 | - if ($name !== 'not') return true; |
|
| 18 | + if ($name !== 'not') { |
|
| 19 | + return true; |
|
| 20 | + } |
|
| 19 | 21 | |
| 20 | 22 | $xpath = new \DomXpath($element->ownerDocument); |
| 21 | 23 | return $this->notElement($args, $xpath, $element); |
@@ -28,7 +30,9 @@ discard block |
||
| 28 | 30 | $xpathString = $this->cssToXpath->getXpath($tokenizer->getTokens()); |
| 29 | 31 | $pseudo = $this->cssToXpath->getPseudo($tokenizer->getTokens()); |
| 30 | 32 | $pseudoMatcher = $this->config->createPseudoMatcher($pseudo); |
| 31 | - if ($this->matches($xpath->query($xpathString), $element, $pseudoMatcher)) return false; |
|
| 33 | + if ($this->matches($xpath->query($xpathString), $element, $pseudoMatcher)) { |
|
| 34 | + return false; |
|
| 35 | + } |
|
| 32 | 36 | } |
| 33 | 37 | return true; |
| 34 | 38 | } |
@@ -37,7 +41,9 @@ discard block |
||
| 37 | 41 | //Find all nodes matched by the expressions in the brackets :not(EXPR) |
| 38 | 42 | foreach ($foundElements as $matchedElement) { |
| 39 | 43 | //Check to see whether this node was matched by the not query |
| 40 | - if ($pseudoMatcher->matches($matchedElement) && $element->isSameNode($matchedElement)) return true; |
|
| 44 | + if ($pseudoMatcher->matches($matchedElement) && $element->isSameNode($matchedElement)) { |
|
| 45 | + return true; |
|
| 46 | + } |
|
| 41 | 47 | } |
| 42 | 48 | return false; |
| 43 | 49 | } |