XPath   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getXPath() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\WSSecurity\Utils;
6
7
use DOMNode;
8
use DOMXPath;
9
use SimpleSAML\WSSecurity\Constants as C;
10
11
/**
12
 * Compilation of utilities for XPath.
13
 *
14
 * @package simplesamlphp/wssecurity
15
 */
16
class XPath extends \SimpleSAML\XMLSecurity\Utils\XPath
17
{
18
    /*
19
     * Get a DOMXPath object that can be used to search for WS Security 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
     *   ws-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('auth', C::NS_AUTH);
32
        $xp->registerNamespace('fed', C::NS_FED);
33
        $xp->registerNamespace('t', C::NS_TRUST_200502);
34
        $xp->registerNamespace('trust', C::NS_TRUST_200512);
35
36
        return $xp;
37
    }
38
}
39