ServiceName   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromXML() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\WSSecurity\XML\wsaw;
6
7
use DOMElement;
8
use SimpleSAML\WSSecurity\Assert\Assert;
9
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10
use SimpleSAML\XML\{SchemaValidatableElementInterface, SchemaValidatableElementTrait};
11
12
/**
13
 * Class defining the ServiceName element
14
 *
15
 * @package simplesamlphp/ws-security
16
 */
17
final class ServiceName extends AbstractServiceNameType implements SchemaValidatableElementInterface
18
{
19
    use SchemaValidatableElementTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\XML\SchemaValidatableElementTrait requires some properties which are not provided by SimpleSAML\WSSecurity\XML\wsaw\ServiceName: $message, $line
Loading history...
20
21
    /**
22
     * Create an instance of this object from its XML representation.
23
     *
24
     * @param \DOMElement $xml
25
     * @return static
26
     *
27
     * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
28
     *   if the qualified name of the supplied element is wrong
29
     */
30
    public static function fromXML(DOMElement $xml): static
31
    {
32
        Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
33
        Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
34
35
        return new static(
36
            $xml->textContent,
37
            self::getOptionalAttribute($xml, 'EndpointName', null),
38
            self::getAttributesNSFromXML($xml),
39
        );
40
    }
41
}
42