Passed
Push — master ( b90b44...f041bb )
by Tim
01:53
created

XPath::getXPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SOAP\Utils;
6
7
use DOMNode;
8
use DOMXPath;
9
use SimpleSAML\SOAP\Constants as C;
10
11
/**
12
 * Compilation of utilities for XPath.
13
 *
14
 * @package simplesamlphp/xml-soap
15
 */
16
class XPath extends \SimpleSAML\XML\Utils\XPath
17
{
18
    /**
19
     * Get a DOMXPath object that can be used to search for SAML elements.
20
     *
21
     * @param \DOMNode $node The document to associate to the DOMXPath object.
22
     *
23
     * @return \DOMXPath A DOMXPath object ready to use in the given document, with several
24
     *   saml-related namespaces already registered.
25
     */
26
    public static function getXPath(DOMNode $node): DOMXPath
27
    {
28
        $xp = parent::getXPath($node);
29
        $xp->registerNamespace('env11', C::NS_SOAP_ENV_11);
30
        $xp->registerNamespace('enc11', C::NS_SOAP_ENC_11);
31
        $xp->registerNamespace('env12', C::NS_SOAP_ENV_12);
32
        $xp->registerNamespace('enc12', C::NS_SOAP_ENC_12);
33
34
        return $xp;
35
    }
36
}
37