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