Passed
Pull Request — master (#280)
by Tim
02:26
created

XPath   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getXPath() 0 9 1
1
<?php
2
3
namespace SimpleSAML\SAML2\Utils;
4
5
use DOMNode;
6
use DOMXPath;
7
use SimpleSAML\SAML2\Constants as C;
8
9
/**
10
 * Compilation of utilities for XPath.
11
 *
12
 * @package simplesamlphp/saml2
13
 */
14
class XPath extends \SimpleSAML\XMLSecurity\Utils\XPath
15
{
16
    /**
17
     * Get a DOMXPath object that can be used to search for SAML elements.
18
     *
19
     * @param \DOMNode $node The document to associate to the DOMXPath object.
20
     *
21
     * @return \DOMXPath A DOMXPath object ready to use in the given document, with several
22
     *   saml-related namespaces already registered.
23
     */
24
    public static function getXPath(DOMNode $node): DOMXPath
25
    {
26
        $xp = parent::getXPath($node);
27
        $xp->registerNamespace('soap-env', C::NS_SOAP);
28
        $xp->registerNamespace('saml_protocol', C::NS_SAMLP);
29
        $xp->registerNamespace('saml_assertion', C::NS_SAML);
30
        $xp->registerNamespace('saml_metadata', C::NS_MD);
31
32
        return $xp;
33
    }
34
}
35