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