1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSchema\XML; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\XML\Assert\Assert; |
9
|
|
|
use SimpleSAML\XMLSchema\Exception\{InvalidDOMElementException, TooManyElementsException}; |
10
|
|
|
use SimpleSAML\XMLSchema\Type\{IDValue, StringValue}; |
11
|
|
|
use SimpleSAML\XMLSchema\Type\Interface\ValueTypeInterface; |
12
|
|
|
|
13
|
|
|
use function array_pop; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Abstract class representing the facet-type. |
17
|
|
|
* |
18
|
|
|
* @package simplesamlphp/xml-common |
19
|
|
|
*/ |
20
|
|
|
abstract class AbstractNoFixedFacet extends AbstractFacet |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* NoFixedFacet constructor |
24
|
|
|
* |
25
|
|
|
* @param \SimpleSAML\XMLSchema\Type\Interface\ValueTypeInterface $value |
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
|
|
|
final public function __construct( |
31
|
|
|
ValueTypeInterface $value, |
32
|
|
|
?Annotation $annotation = null, |
33
|
|
|
?IDValue $id = null, |
34
|
|
|
array $namespacedAttributes = [], |
35
|
|
|
) { |
36
|
|
|
parent::__construct($value, null, $annotation, $id, $namespacedAttributes); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Create an instance of this object from its XML representation. |
42
|
|
|
* |
43
|
|
|
* @param \DOMElement $xml |
44
|
|
|
* @return static |
45
|
|
|
* |
46
|
|
|
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException |
47
|
|
|
* if the qualified name of the supplied element is wrong |
48
|
|
|
*/ |
49
|
|
|
public static function fromXML(DOMElement $xml): static |
50
|
|
|
{ |
51
|
|
|
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
52
|
|
|
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
53
|
|
|
|
54
|
|
|
$annotation = Annotation::getChildrenOfClass($xml); |
55
|
|
|
Assert::maxCount($annotation, 1, TooManyElementsException::class); |
56
|
|
|
|
57
|
|
|
return new static( |
58
|
|
|
self::getAttribute($xml, 'value', StringValue::class), |
59
|
|
|
array_pop($annotation), |
60
|
|
|
self::getOptionalAttribute($xml, 'id', IDValue::class, null), |
61
|
|
|
self::getAttributesNSFromXML($xml), |
62
|
|
|
); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|