Passed
Push — master ( a3fda0...7c0590 )
by Tim
14:58 queued 13:28
created

StatusDetail   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 67
rs 10
c 0
b 0
f 0
wmc 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\samlp;
6
7
use DOMElement;
8
use SimpleSAML\SAML2\Assert\Assert;
9
use SimpleSAML\XML\ExtendableElementTrait;
10
use SimpleSAML\XML\SchemaValidatableElementInterface;
11
use SimpleSAML\XML\SchemaValidatableElementTrait;
12
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
13
use SimpleSAML\XMLSchema\XML\Constants\NS;
14
15
/**
16
 * SAML StatusDetail data type.
17
 *
18
 * @package simplesamlphp/saml2
19
 */
20
final class StatusDetail extends AbstractSamlpElement implements SchemaValidatableElementInterface
21
{
22
    use ExtendableElementTrait;
23
    use SchemaValidatableElementTrait;
24
25
26
    /** The namespace-attribute for the xs:any element */
27
    public const string XS_ANY_ELT_NAMESPACE = NS::ANY;
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 27 at column 24
Loading history...
28
29
30
    /**
31
     * Initialize a samlp:StatusDetail
32
     *
33
     * @param \SimpleSAML\XML\SerializableElementInterface[] $details
34
     */
35
    public function __construct(array $details = [])
36
    {
37
        $this->setElements($details);
38
    }
39
40
41
    /**
42
     * Test if an object, at the state it's in, would produce an empty XML-element
43
     */
44
    public function isEmptyElement(): bool
45
    {
46
        return empty($this->elements);
47
    }
48
49
50
    /**
51
     * Convert XML into a StatusDetail
52
     *
53
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
54
     *   if the qualified name of the supplied element is wrong
55
     */
56
    public static function fromXML(DOMElement $xml): static
57
    {
58
        Assert::same($xml->localName, 'StatusDetail', InvalidDOMElementException::class);
59
        Assert::same($xml->namespaceURI, StatusDetail::NS, InvalidDOMElementException::class);
60
61
        return new static(
62
            self::getChildElementsFromXML($xml),
63
        );
64
    }
65
66
67
    /**
68
     * Convert this StatusDetail to XML.
69
     */
70
    public function toXML(?DOMElement $parent = null): DOMElement
71
    {
72
        $e = $this->instantiateParentElement($parent);
73
74
        foreach ($this->getElements() as $detail) {
75
            $detail->toXML($e);
76
        }
77
78
        return $e;
79
    }
80
}
81