AbstractEmptyType   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 45
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toXML() 0 3 1
A fromXML() 0 12 1
A __construct() 0 2 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