-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathAnyAttribute.php
More file actions
57 lines (46 loc) · 1.85 KB
/
Copy pathAnyAttribute.php
File metadata and controls
57 lines (46 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
declare(strict_types=1);
namespace SimpleSAML\XMLSchema\XML;
use DOMElement;
use SimpleSAML\XML\Assert\Assert;
use SimpleSAML\XML\SchemaValidatableElementInterface;
use SimpleSAML\XML\SchemaValidatableElementTrait;
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
use SimpleSAML\XMLSchema\Type\IDValue;
use SimpleSAML\XMLSchema\Type\Schema\NamespaceListValue;
use SimpleSAML\XMLSchema\Type\Schema\ProcessContentsValue;
use function array_last;
/**
* Class representing the anyAttribute element
*
* @package simplesamlphp/xml-common
*/
final class AnyAttribute extends AbstractWildcard implements SchemaValidatableElementInterface
{
use SchemaValidatableElementTrait;
public const string LOCALNAME = 'anyAttribute';
/**
* Create an instance of this object from its XML representation.
*
* @param \DOMElement $xml
* @return static
*
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
* if the qualified name of the supplied element is wrong
*/
public static function fromXML(DOMElement $xml): static
{
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
$annotation = Annotation::getChildrenOfClass($xml);
Assert::maxCount($annotation, 1, TooManyElementsException::class);
return new static(
self::getOptionalAttribute($xml, 'namespace', NamespaceListValue::class, null),
self::getOptionalAttribute($xml, 'processContents', ProcessContentsValue::class, null),
array_last($annotation),
self::getOptionalAttribute($xml, 'id', IDValue::class, null),
self::getAttributesNSFromXML($xml),
);
}
}