AbstractEmptyType::fromXML()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 12
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\WSSecurity\XML\sp_200702;
6
7
use DOMElement;
8
use SimpleSAML\WSSecurity\Assert\Assert;
9
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10
11
use function sprintf;
12
13
/**
14
 * Class representing WS security policy EmptyType.
15
 *
16
 * @package simplesamlphp/ws-security
17
 */
18
abstract class AbstractEmptyType extends AbstractSpElement
19
{
20
    /**
21
     * AbstractEmptyType constructor.
22
     */
23
    final public function __construct()
24
    {
25
    }
26
27
28
    /**
29
     * Initialize an EmptyType.
30
     *
31
     * Note: this method cannot be used when extending this class, if the constructor has a different signature.
32
     *
33
     * @param \DOMElement $xml The XML element we should load.
34
     * @return static
35
     *
36
     * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
37
     *   if the qualified name of the supplied element is wrong
38
     */
39
    public static function fromXML(DOMElement $xml): static
40
    {
41
        $qualifiedName = static::getClassName(static::class);
42
        Assert::eq(
43
            $xml->localName,
44
            $qualifiedName,
45
            sprintf('Unexpected name for EmptyType: %s. Expected: %s.', $xml->localName, $qualifiedName),
46
            InvalidDOMElementException::class,
47
        );
48
49
50
        return new static();
51
    }
52
53
54
    /**
55
     * Convert this element to XML.
56
     *
57
     * @param \DOMElement|null $parent The element we should append this element to.
58
     * @return \DOMElement
59
     */
60
    public function toXML(?DOMElement $parent = null): DOMElement
61
    {
62
        return $this->instantiateParentElement($parent);
63
    }
64
}
65