Passed
Push — master ( 9d0495...a5c7c1 )
by Tim
02:21
created

XPath::findElement()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 4
nop 2
dl 0
loc 10
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Utils;
6
7
use DOMNode;
8
use DOMXPath;
9
use SimpleSAML\XMLSecurity\Constants as C;
10
use SimpleSAML\XPath\XPath as XPathUtils;
11
12
/**
13
 * Compilation of utilities for XPath.
14
 *
15
 * @package simplesamlphp/xml-security
16
 */
17
class XPath extends XPathUtils
18
{
19
    /**
20
     * Get a DOMXPath object that can be used to search for XMLDSIG elements.
21
     *
22
     * @param \DOMNode $node The document to associate to the DOMXPath object.
23
     * @param bool $autoregister Whether to auto-register all namespaces used in the document
24
     *
25
     * @return \DOMXPath A DOMXPath object ready to use in the given document, with the XMLDSIG namespace already
26
     * registered.
27
     */
28
    public static function getXPath(DOMNode $node, bool $autoregister = false): DOMXPath
29
    {
30
        $xp = parent::getXPath($node, $autoregister);
31
32
        $xp->registerNamespace('ds', C::NS_XDSIG);
33
        $xp->registerNamespace('xenc', C::NS_XENC);
34
35
        return $xp;
36
    }
37
}
38