InclusiveNamespaces::getPrefixes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\XML\ec;
6
7
use DOMElement;
8
use SimpleSAML\XML\SchemaValidatableElementInterface;
9
use SimpleSAML\XML\SchemaValidatableElementTrait;
10
use SimpleSAML\XMLSchema\Type\NMTokensValue;
11
12
use function strval;
13
14
/**
15
 * Class implementing InclusiveNamespaces
16
 *
17
 * @package simplesamlphp/xml-security
18
 */
19
class InclusiveNamespaces extends AbstractEcElement implements SchemaValidatableElementInterface
20
{
21
    use SchemaValidatableElementTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\XML\SchemaValidatableElementTrait requires some properties which are not provided by SimpleSAML\XMLSecurity\XML\ec\InclusiveNamespaces: $message, $line
Loading history...
22
23
24
    /**
25
     * Initialize the InclusiveNamespaces element.
26
     *
27
     * @param \SimpleSAML\XMLSchema\Type\NMTokensValue|null $prefixes
28
     */
29
    final public function __construct(
30
        protected ?NMTokensValue $prefixes,
31
    ) {
32
    }
33
34
35
    /**
36
     * Get the prefixes specified by this element.
37
     *
38
     * @return \SimpleSAML\XMLSchema\Type\NMTokensValue|null
39
     */
40
    public function getPrefixes(): ?NMTokensValue
41
    {
42
        return $this->prefixes;
43
    }
44
45
46
    /**
47
     * Convert XML into an InclusiveNamespaces element.
48
     *
49
     * @param \DOMElement $xml The XML element we should load.
50
     * @return static
51
     */
52
    public static function fromXML(DOMElement $xml): static
53
    {
54
        return new static(
55
            self::getOptionalAttribute($xml, 'PrefixList', NMTokensValue::class, null),
56
        );
57
    }
58
59
60
    /**
61
     * Convert this InclusiveNamespaces to XML.
62
     *
63
     * @param \DOMElement|null $parent The element we should append this InclusiveNamespaces to.
64
     * @return \DOMElement
65
     */
66
    public function toXML(?DOMElement $parent = null): DOMElement
67
    {
68
        $e = $this->instantiateParentElement($parent);
69
70
        if ($this->getPrefixes() !== null) {
71
            $e->setAttribute('PrefixList', strval($this->getPrefixes()));
72
        }
73
74
        return $e;
75
    }
76
}
77