1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSchema\XML; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\XMLSchema\Type\BooleanValue; |
9
|
|
|
use SimpleSAML\XMLSchema\Type\IDValue; |
10
|
|
|
use SimpleSAML\XMLSchema\Type\Interface\ValueTypeInterface; |
11
|
|
|
|
12
|
|
|
use function strval; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Abstract class representing the facet-type. |
16
|
|
|
* |
17
|
|
|
* @package simplesamlphp/xml-common |
18
|
|
|
*/ |
19
|
|
|
abstract class AbstractFacet extends AbstractAnnotated |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Facet constructor |
23
|
|
|
* |
24
|
|
|
* @param \SimpleSAML\XMLSchema\Type\Interface\ValueTypeInterface $value |
25
|
|
|
* @param \SimpleSAML\XMLSchema\Type\BooleanValue $fixed |
26
|
|
|
* @param \SimpleSAML\XMLSchema\XML\Annotation|null $annotation |
27
|
|
|
* @param \SimpleSAML\XMLSchema\Type\IDValue|null $id |
28
|
|
|
* @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes |
29
|
|
|
*/ |
30
|
|
|
public function __construct( |
31
|
|
|
protected ValueTypeInterface $value, |
32
|
|
|
protected ?BooleanValue $fixed = null, |
33
|
|
|
?Annotation $annotation = null, |
34
|
|
|
?IDValue $id = null, |
35
|
|
|
array $namespacedAttributes = [], |
36
|
|
|
) { |
37
|
|
|
parent::__construct($annotation, $id, $namespacedAttributes); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Collect the value of the value-property |
43
|
|
|
* |
44
|
|
|
* @return \SimpleSAML\XMLSchema\Type\Interface\ValueTypeInterface |
45
|
|
|
*/ |
46
|
|
|
public function getValue(): ValueTypeInterface |
47
|
|
|
{ |
48
|
|
|
return $this->value; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Collect the value of the fixed-property |
54
|
|
|
* |
55
|
|
|
* @return \SimpleSAML\XMLSchema\Type\BooleanValue|null |
56
|
|
|
*/ |
57
|
|
|
public function getFixed(): ?BooleanValue |
58
|
|
|
{ |
59
|
|
|
return $this->fixed; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Add this Facet to an XML element. |
65
|
|
|
* |
66
|
|
|
* @param \DOMElement|null $parent The element we should append this facet to. |
67
|
|
|
* @return \DOMElement |
68
|
|
|
*/ |
69
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
70
|
|
|
{ |
71
|
|
|
$e = parent::toXML($parent); |
72
|
|
|
|
73
|
|
|
$e->setAttribute('value', strval($this->getValue())); |
74
|
|
|
|
75
|
|
|
if ($this->getFixed() !== null) { |
76
|
|
|
$e->setAttribute('fixed', strval($this->getFixed())); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
return $e; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|