Issues (16)

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