1 | <?php |
||
8 | class CssToXpath { |
||
9 | private $specialChars = [' ', '.', '>', '~', '#', ':', '[', ']']; |
||
10 | private $translators = []; |
||
11 | private $css; |
||
12 | private $depth; |
||
13 | private static $valueParser; |
||
14 | |||
15 | public function __construct($css, Value $valueParser, $prefix = '') { |
||
16 | self::$valueParser = $valueParser; |
||
17 | $this->css = str_replace([' >', '> '],['>', '>'], trim($css)); |
||
18 | $this->translators = [ |
||
19 | ' ' => function($string) use ($prefix) { return '//' . $prefix . $string; }, |
||
20 | '' => function($string) use ($prefix) { return '/' . $prefix . $string; }, |
||
21 | '>' => function($string) use ($prefix) { return '/' . $prefix . $string; }, |
||
22 | '#' => function($string) { return '[@id=\'' . $string . '\']'; }, |
||
23 | '.' => function($string) { return '[contains(concat(\' \', normalize-space(@class), \' \'), \' ' . $string . ' \')]'; }, |
||
24 | '[' => function($string, $xpath) { return '[' .'php:function(\'\Transphporm\Parser\CssToXpath::processAttr\', \'' . $string . '\', .)' . ']'; }, |
||
|
|||
25 | ']' => function() { return ''; } |
||
26 | ]; |
||
27 | } |
||
28 | |||
29 | private function createSelector() { |
||
35 | |||
36 | //XPath only allows registering of static functions... this is a hacky workaround for that |
||
37 | public static function processAttr($attr, $element) { |
||
52 | |||
53 | private static function compare($comparator, $a, $b) { |
||
57 | |||
58 | //split the css into indivudal functions |
||
59 | private function split($css) { |
||
74 | |||
75 | public function getXpath() { |
||
88 | |||
89 | public function getDepth() { |
||
92 | |||
93 | public function getPseudo() { |
||
98 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.