SupportedEnvelope   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 54
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A fromXML() 0 8 1
A getQName() 0 3 1
A __construct() 0 3 1
A toXML() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SOAP\XML\env_200305;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10
11
/**
12
 * Class representing a env:SupportedEnvelope element.
13
 *
14
 * @package simplesaml/xml-soap
15
 */
16
final class SupportedEnvelope extends AbstractSoapElement
17
{
18
    /**
19
     * Initialize a soap:SupportedEnvelope
20
     *
21
     * @param string $qname
22
     */
23
    public function __construct(
24
        protected string $qname,
25
    ) {
26
    }
27
28
29
    /**
30
     * @return string
31
     */
32
    public function getQName(): string
33
    {
34
        return $this->qname;
35
    }
36
37
38
    /**
39
     * Convert XML into an SupportedEnvelope element
40
     *
41
     * @param \DOMElement $xml The XML element we should load
42
     * @return static
43
     *
44
     * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
45
     *   If the qualified name of the supplied element is wrong
46
     */
47
    public static function fromXML(DOMElement $xml): static
48
    {
49
        Assert::same($xml->localName, 'SupportedEnvelope', InvalidDOMElementException::class);
50
        Assert::same($xml->namespaceURI, SupportedEnvelope::NS, InvalidDOMElementException::class);
51
52
        $qname = self::getAttribute($xml, 'qname');
53
54
        return new static($qname);
55
    }
56
57
58
    /**
59
     * Convert this SupportedEnvelope to XML.
60
     *
61
     * @param \DOMElement|null $parent The element we should add this SupportedEnvelope to.
62
     * @return \DOMElement This SupportedEnvelope-element.
63
     */
64
    public function toXML(?DOMElement $parent = null): DOMElement
65
    {
66
        $e = $this->instantiateParentElement($parent);
67
        $e->setAttribute('qname', $this->getQName());
68
69
        return $e;
70
    }
71
}
72