XPath::getXPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML11\Utils;
6
7
use DOMNode;
8
use DOMXPath;
9
use SimpleSAML\SAML11\Constants as C;
10
11
/**
12
 * Compilation of utilities for XPath.
13
 *
14
 * @package simplesamlphp/saml11
15
 */
16
class XPath extends \SimpleSAML\XMLSecurity\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
     * @param bool $autoregister Whether to auto-register all namespaces used in the document
23
     *
24
     * @return \DOMXPath A DOMXPath object ready to use in the given document, with several
25
     *   saml-related namespaces already registered.
26
     */
27
    public static function getXPath(DOMNode $node, bool $autoregister = false): DOMXPath
28
    {
29
        $xp = parent::getXPath($node, $autoregister);
30
31
        $xp->registerNamespace('saml_protocol', C::NS_SAMLP);
32
        $xp->registerNamespace('saml_assertion', C::NS_SAML);
33
34
        return $xp;
35
    }
36
}
37