Passed
Push — master ( 6954cd...ed9dd2 )
by Tim
04:01 queued 01:23
created

SessionIndex::fromXML()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\samlp;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10
use SimpleSAML\XML\XMLStringElementTrait;
11
12
/**
13
 * Class representing a samlp:SessionIndex element.
14
 *
15
 * @package simplesaml/saml2
16
 */
17
final class SessionIndex extends AbstractSamlpElement
18
{
19
    use XMLStringElementTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\XML\XMLStringElementTrait requires some properties which are not provided by SimpleSAML\SAML2\XML\samlp\SessionIndex: $localName, $namespaceURI
Loading history...
20
21
22
    /**
23
     * Validate the content of the element.
24
     *
25
     * @param string $content  The value to go in the XML textContent
26
     * @throws \Exception on failure
27
     * @return void
28
     */
29
    protected function validateContent(string $content): void
30
    {
31
        Assert::notWhitespaceOnly($content);
32
    }
33
34
35
    /**
36
     * Convert XML into an SessionIndex
37
     *
38
     * @param \DOMElement $xml The XML element we should load
39
     * @return self
40
     *
41
     * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
42
     *   If the qualified name of the supplied element is wrong
43
     */
44
    public static function fromXML(DOMElement $xml): object
45
    {
46
        Assert::same($xml->localName, 'SessionIndex', InvalidDOMElementException::class);
47
        Assert::same($xml->namespaceURI, SessionIndex::NS, InvalidDOMElementException::class);
48
49
        return new self($xml->textContent);
50
    }
51
}
52
53