Passed
Push — master ( 94fef1...0de58e )
by Tim
13:22
created

XPath::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\WSSecurity\XML\sp_200507;
6
7
use DOMNodeList;
8
use DOMXPath;
9
use SimpleSAML\Assert\Assert;
10
use SimpleSAML\XML\DOMDocumentFactory;
11
use SimpleSAML\XML\StringElementTrait;
12
13
/**
14
 * An XPath element
15
 *
16
 * @package simplesamlphp/ws-security
17
 */
18
final class XPath extends AbstractSpElement
19
{
20
    use StringElementTrait;
21
22
23
    /**
24
     * Initialize an XPath.
25
     *
26
     * @param string $content
27
     */
28
    public function __construct(
29
        string $content,
30
    ) {
31
        $this->setContent($content);
32
    }
33
34
35
    /**
36
     * Validate the content of the element.
37
     *
38
     * @param string $content  The value to go in the XML textContent
39
     * @throws \SimpleSAML\XML\Exception\SchemaViolationException on failure
40
     * @return void
41
     */
42
    protected function validateContent(string $content): void
43
    {
44
        $dom = new DOMXPath(DOMDocumentFactory::create());
45
        $result = $dom->evaluate($content);
46
        Assert::isInstanceOf($result, DOMNodeList::class);
47
    }
48
}
49