AttributeDesignator   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 7
c 1
b 0
f 0
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromXML() 0 8 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, SAMLStringValue};
10
use SimpleSAML\XML\{SchemaValidatableElementInterface, SchemaValidatableElementTrait};
11
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
12
13
/**
14
 * Class representing a saml:AttributeDesignator element.
15
 *
16
 * @package simplesamlphp/saml11
17
 */
18
final class AttributeDesignator extends AbstractAttributeDesignatorType implements SchemaValidatableElementInterface
19
{
20
    use SchemaValidatableElementTrait;
21
22
    /**
23
     * Convert XML into an AttributeDesignatorType
24
     *
25
     * @param \DOMElement $xml The XML element we should load
26
     * @return static
27
     *
28
     * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
29
     *   if the qualified name of the supplied element is wrong
30
     */
31
    public static function fromXML(DOMElement $xml): static
32
    {
33
        Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
34
        Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
35
36
        return new static(
37
            self::getAttribute($xml, 'AttributeName', SAMLStringValue::class),
38
            self::getAttribute($xml, 'AttributeNamespace', SAMLAnyURIValue::class),
39
        );
40
    }
41
}
42