Passed
Pull Request — master (#19)
by Tim
02:42
created

XPath::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\WSSecurity\XML\sp_200702;
6
7
use DOMNodeList;
8
use DOMXPath;
9
use SimpleSAML\WSSecurity\Assert\Assert;
10
use SimpleSAML\XML\DOMDocumentFactory;
11
use SimpleSAML\XML\TypedTextContentTrait;
12
use SimpleSAML\XMLSchema\Type\StringValue;
13
14
/**
15
 * An XPath element
16
 *
17
 * @package simplesamlphp/ws-security
18
 */
19
final class XPath extends AbstractSpElement
20
{
21
    use TypedTextContentTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\XML\TypedTextContentTrait requires some properties which are not provided by SimpleSAML\WSSecurity\XML\sp_200702\XPath: $localName, $namespaceURI
Loading history...
22
23
24
    /** @var string */
25
    public const TEXTCONTENT_TYPE = StringValue::class;
26
27
28
    /**
29
     * Validate the content of the element.
30
     *
31
     * @param string $content  The value to go in the XML textContent
32
     * @throws \SimpleSAML\XMLSchema\Exception\SchemaViolationException on failure
33
     * @return void
34
     */
35
    protected function validateContent(string $content): void
36
    {
37
        $dom = new DOMXPath(DOMDocumentFactory::create());
38
        $result = $dom->evaluate($content);
39
        Assert::isInstanceOf($result, DOMNodeList::class);
40
    }
41
}
42