Conditions | 4 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
25 | public static function getXPath(DOMNode $node): DOMXPath |
||
26 | { |
||
27 | static $xpCache = null; |
||
28 | |||
29 | if ($node instanceof DOMDocument) { |
||
30 | $doc = $node; |
||
31 | } else { |
||
32 | $doc = $node->ownerDocument; |
||
33 | Assert::notNull($doc); |
||
34 | } |
||
35 | |||
36 | if ($xpCache === null || !$xpCache->document->isSameNode($doc)) { |
||
37 | $xpCache = new DOMXPath($doc); |
||
|
|||
38 | } |
||
39 | |||
40 | return $xpCache; |
||
41 | } |
||
63 |