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