1 | <?php |
||
18 | class XPathQuery |
||
19 | { |
||
20 | private $_query; |
||
21 | /** @var \DOMXPath */ |
||
22 | private $_xpath; |
||
23 | private $_context; |
||
24 | |||
25 | public function with(string $prefix, string $namespace) |
||
26 | { |
||
27 | $this->_xpath->registerNamespace($prefix, $namespace); |
||
28 | |||
29 | return $this; |
||
30 | } |
||
31 | |||
32 | public function query(string $query = null) |
||
39 | |||
40 | public function evaluate(string $query = null) |
||
44 | |||
45 | public function __construct(string $query, XmlElement $context) |
||
55 | |||
56 | /** |
||
57 | * Hack for supporting XPath outside of standard XML implementation. |
||
58 | * Why? Because simplexml sucks so much. |
||
59 | * DOM sucks even more, and I'm better with writing one hack for xpath |
||
60 | * than with writing hack for almost everyfuckingthing™. |
||
61 | * |
||
62 | * @param $path |
||
63 | * @return false|XmlElement |
||
64 | */ |
||
65 | private function getElementFromPath($path) |
||
86 | } |
||
87 |