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