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