Issues (16)

src/SOAP11/XML/Detail.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SOAP11\XML;
6
7
use DOMElement;
8
use SimpleSAML\SOAP11\Assert\Assert;
9
use SimpleSAML\XML\AbstractElement;
10
use SimpleSAML\XML\ExtendableAttributesTrait;
11
use SimpleSAML\XML\ExtendableElementTrait;
12
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
13
use SimpleSAML\XMLSchema\XML\Constants\NS;
14
15
/**
16
 * Class representing a SOAP-ENV:Detail element.
17
 *
18
 * @package simplesaml/xml-soap
19
 */
20
final class Detail extends AbstractElement
21
{
22
    use ExtendableAttributesTrait;
23
    use ExtendableElementTrait;
24
25
26
    /** @var string */
27
    public const LOCALNAME = 'detail';
28
29
    /** @var null */
30
    public const NS = null;
31
32
    /** @var null */
33
    public const NS_PREFIX = null;
34
35
    /** The namespace-attribute for the xs:any element */
36
    public const XS_ANY_ELT_NAMESPACE = NS::ANY;
37
38
    /** The namespace-attribute for the xs:anyAttribute element */
39
    public const XS_ANY_ATTR_NAMESPACE = NS::ANY;
40
41
42
    /**
43
     * Initialize a soap:Detail
44
     *
45
     * @param list<\SimpleSAML\XML\SerializableElementInterface> $children
46
     * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
0 ignored issues
show
The type SimpleSAML\SOAP11\XML\list was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
47
     */
48
    public function __construct(array $children = [], array $namespacedAttributes = [])
49
    {
50
        $this->setElements($children);
51
        $this->setAttributesNS($namespacedAttributes);
52
    }
53
54
55
    /**
56
     * Test if an object, at the state it's in, would produce an empty XML-element
57
     *
58
     * @return bool
59
     */
60
    public function isEmptyElement(): bool
61
    {
62
        return empty($this->elements) && empty($this->namespacedAttributes);
63
    }
64
65
66
    /*
67
     * Convert XML into an Detail element
68
     *
69
     * @param \DOMElement $xml The XML element we should load
70
     * @return static
71
     *
72
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
73
     *   If the qualified name of the supplied element is wrong
74
     */
75
    public static function fromXML(DOMElement $xml): static
76
    {
77
        Assert::same($xml->localName, 'detail', InvalidDOMElementException::class);
78
        Assert::same($xml->namespaceURI, Detail::NS, InvalidDOMElementException::class);
79
80
        return new static(
81
            self::getChildElementsFromXML($xml),
82
            self::getAttributesNSFromXML($xml),
83
        );
84
    }
85
86
87
    /**
88
     * Convert this Detail to XML.
89
     *
90
     * @param \DOMElement|null $parent The element we should add this Detail to.
91
     * @return \DOMElement This Detail-element.
92
     */
93
    public function toXML(?DOMElement $parent = null): DOMElement
94
    {
95
        $e = $this->instantiateParentElement($parent);
96
97
        foreach ($this->getAttributesNS() as $attr) {
98
            $attr->toXML($e);
99
        }
100
101
        foreach ($this->getElements() as $child) {
102
            $child->toXML($e);
103
        }
104
105
        return $e;
106
    }
107
}
108