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\XML\SchemaValidatableElementInterface; |
10
|
|
|
use SimpleSAML\XML\SchemaValidatableElementTrait; |
11
|
|
|
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; |
12
|
|
|
use SimpleSAML\XMLSchema\Exception\TooManyElementsException; |
13
|
|
|
use SimpleSAML\XMLSchema\Type\BooleanValue; |
14
|
|
|
use SimpleSAML\XMLSchema\Type\IDValue; |
15
|
|
|
use SimpleSAML\XMLSchema\Type\StringValue; |
16
|
|
|
use SimpleSAML\XMLSchema\XML\Interface\FacetInterface; |
17
|
|
|
|
18
|
|
|
use function array_pop; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Class representing the maxInclusive element |
22
|
|
|
* |
23
|
|
|
* @package simplesamlphp/xml-common |
24
|
|
|
*/ |
25
|
|
|
final class MaxInclusive extends AbstractFacet implements SchemaValidatableElementInterface, FacetInterface |
26
|
|
|
{ |
27
|
|
|
use SchemaValidatableElementTrait; |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
/** @var string */ |
31
|
|
|
public const LOCALNAME = 'maxInclusive'; |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Create an instance of this object from its XML representation. |
36
|
|
|
* |
37
|
|
|
* @param \DOMElement $xml |
38
|
|
|
* @return static |
39
|
|
|
* |
40
|
|
|
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException |
41
|
|
|
* if the qualified name of the supplied element is wrong |
42
|
|
|
*/ |
43
|
|
|
public static function fromXML(DOMElement $xml): static |
44
|
|
|
{ |
45
|
|
|
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
46
|
|
|
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
47
|
|
|
|
48
|
|
|
$annotation = Annotation::getChildrenOfClass($xml); |
49
|
|
|
Assert::maxCount($annotation, 1, TooManyElementsException::class); |
50
|
|
|
|
51
|
|
|
return new static( |
52
|
|
|
self::getAttribute($xml, 'value', StringValue::class), |
53
|
|
|
self::getOptionalAttribute($xml, 'fixed', BooleanValue::class, null), |
54
|
|
|
array_pop($annotation), |
55
|
|
|
self::getOptionalAttribute($xml, 'id', IDValue::class, null), |
56
|
|
|
self::getAttributesNSFromXML($xml), |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|