Issues (16)

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

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