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, ExtendableElementTrait};
11
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
12
use SimpleSAML\XMLSchema\XML\Enumeration\NamespaceEnum;
13
14
/**
15
 * Class representing a SOAP-ENV:Detail element.
16
 *
17
 * @package simplesaml/xml-soap
18
 */
19
final class Detail extends AbstractElement
20
{
21
    use ExtendableAttributesTrait;
22
    use ExtendableElementTrait;
23
24
    /** @var string */
25
    public const LOCALNAME = 'detail';
26
27
    /** @var null */
28
    public const NS = null;
29
30
    /** @var null */
31
    public const NS_PREFIX = null;
32
33
    /** The namespace-attribute for the xs:any element */
34
    public const XS_ANY_ELT_NAMESPACE = NamespaceEnum::Any;
35
36
    /** The namespace-attribute for the xs:anyAttribute element */
37
    public const XS_ANY_ATTR_NAMESPACE = NamespaceEnum::Any;
38
39
40
    /**
41
     * Initialize a soap:Detail
42
     *
43
     * @param list<\SimpleSAML\XML\SerializableElementInterface> $children
44
     * @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...
45
     */
46
    public function __construct(array $children = [], array $namespacedAttributes = [])
47
    {
48
        $this->setElements($children);
49
        $this->setAttributesNS($namespacedAttributes);
50
    }
51
52
53
    /**
54
     * Test if an object, at the state it's in, would produce an empty XML-element
55
     *
56
     * @return bool
57
     */
58
    public function isEmptyElement(): bool
59
    {
60
        return empty($this->elements) && empty($this->namespacedAttributes);
61
    }
62
63
64
    /*
65
     * Convert XML into an Detail element
66
     *
67
     * @param \DOMElement $xml The XML element we should load
68
     * @return static
69
     *
70
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
71
     *   If the qualified name of the supplied element is wrong
72
     */
73
    public static function fromXML(DOMElement $xml): static
74
    {
75
        Assert::same($xml->localName, 'detail', InvalidDOMElementException::class);
76
        Assert::same($xml->namespaceURI, Detail::NS, InvalidDOMElementException::class);
77
78
        return new static(
79
            self::getChildElementsFromXML($xml),
80
            self::getAttributesNSFromXML($xml),
81
        );
82
    }
83
84
85
    /**
86
     * Convert this Detail to XML.
87
     *
88
     * @param \DOMElement|null $parent The element we should add this Detail to.
89
     * @return \DOMElement This Detail-element.
90
     */
91
    public function toXML(?DOMElement $parent = null): DOMElement
92
    {
93
        $e = $this->instantiateParentElement($parent);
94
95
        foreach ($this->getAttributesNS() as $attr) {
96
            $attr->toXML($e);
97
        }
98
99
        /** @psalm-var \SimpleSAML\XML\SerializableElementInterface $child */
100
        foreach ($this->getElements() as $child) {
101
            $child->toXML($e);
102
        }
103
104
        return $e;
105
    }
106
}
107