AttributeDesignator::fromXML()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML11\XML\saml;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\SAML11\Type\SAMLAnyURIValue;
10
use SimpleSAML\SAML11\Type\SAMLStringValue;
11
use SimpleSAML\XML\SchemaValidatableElementInterface;
12
use SimpleSAML\XML\SchemaValidatableElementTrait;
13
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
14
15
/**
16
 * Class representing a saml:AttributeDesignator element.
17
 *
18
 * @package simplesamlphp/saml11
19
 */
20
final class AttributeDesignator extends AbstractAttributeDesignatorType implements SchemaValidatableElementInterface
21
{
22
    use SchemaValidatableElementTrait;
23
24
25
    /**
26
     * Convert XML into an AttributeDesignatorType
27
     *
28
     * @param \DOMElement $xml The XML element we should load
29
     * @return static
30
     *
31
     * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
32
     *   if the qualified name of the supplied element is wrong
33
     */
34
    public static function fromXML(DOMElement $xml): static
35
    {
36
        Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
37
        Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
38
39
        return new static(
40
            self::getAttribute($xml, 'AttributeName', SAMLStringValue::class),
41
            self::getAttribute($xml, 'AttributeNamespace', SAMLAnyURIValue::class),
42
        );
43
    }
44
}
45