Conditions | 5 |
Paths | 6 |
Total Lines | 24 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 7 | ||
Bugs | 2 | Features | 0 |
1 | <?php |
||
15 | public function match($pseudo, \DomElement $element) { |
||
16 | |||
17 | $pos = strpos($pseudo, '['); |
||
18 | if ($pos === false) return true; |
||
19 | |||
20 | $name = substr($pseudo, 0, $pos); |
||
21 | if (!is_callable([$this->functionSet, $name])) return true; |
||
22 | |||
23 | $bracketMatcher = new \Transphporm\Parser\BracketMatcher($pseudo); |
||
24 | $criteria = $bracketMatcher->match('[', ']'); |
||
25 | |||
26 | $valueParser = new \Transphporm\Parser\Value($this->functionSet); |
||
27 | |||
28 | $criteria = $name . '(' . $criteria; |
||
29 | |||
30 | $pos = strpos($pseudo, '!'); |
||
31 | if ($pos === false) $pos = strpos($pseudo, '='); |
||
32 | if ($pos === false) { |
||
33 | $criteria .= ')=true'; |
||
34 | } |
||
35 | else $criteria = substr_replace($criteria, ')', $pos, 0); |
||
36 | |||
37 | return $valueParser->parse($criteria, $element)[0]; |
||
38 | } |
||
39 | } |