Upgrade::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 1
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\Constants as C;
10
use SimpleSAML\XML\SchemaValidatableElementInterface;
11
use SimpleSAML\XML\SchemaValidatableElementTrait;
12
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
13
use SimpleSAML\XMLSchema\Exception\SchemaViolationException;
14
15
/**
16
 * Class representing a env:Upgrade element.
17
 *
18
 * @package simplesaml/xml-soap
19
 */
20
final class Upgrade extends AbstractSoapElement implements SchemaValidatableElementInterface
0 ignored issues
show
Bug introduced by
The type SimpleSAML\SOAP12\XML\AbstractSoapElement 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...
21
{
22
    use SchemaValidatableElementTrait;
23
24
25
    /**
26
     * Initialize a env:Upgrade
27
     *
28
     * @param \SimpleSAML\SOAP12\XML\SupportedEnvelope[] $supportedEnvelope
29
     */
30
    public function __construct(
31
        protected array $supportedEnvelope,
32
    ) {
33
        Assert::maxCount($supportedEnvelope, C::UNBOUNDED_LIMIT);
34
        Assert::minCount($supportedEnvelope, 1, SchemaViolationException::class);
35
        Assert::allIsInstanceOf($supportedEnvelope, SupportedEnvelope::class, SchemaViolationException::class);
36
    }
37
38
39
    /**
40
     * @return \SimpleSAML\SOAP12\XML\SupportedEnvelope[]
41
     */
42
    public function getSupportedEnvelope(): array
43
    {
44
        return $this->supportedEnvelope;
45
    }
46
47
48
    /**
49
     * Convert this element to XML.
50
     *
51
     * @param \DOMElement|null $parent The element we should append this element to.
52
     */
53
    public function toXML(?DOMElement $parent = null): DOMElement
54
    {
55
        $e = $this->instantiateParentElement($parent);
56
57
        foreach ($this->getSupportedEnvelope() as $supportedEnvelope) {
58
            $supportedEnvelope->toXML($e);
59
        }
60
61
        return $e;
62
    }
63
64
65
    /**
66
     * Convert XML into a Upgrade
67
     *
68
     * @param \DOMElement $xml The XML element we should load
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, 'Upgrade', InvalidDOMElementException::class);
76
        Assert::same($xml->namespaceURI, Upgrade::NS, InvalidDOMElementException::class);
77
78
        $supportedEnvelope = SupportedEnvelope::getChildrenOfClass($xml);
79
        Assert::minCount($supportedEnvelope, 1, SchemaViolationException::class);
80
81
        return new static($supportedEnvelope);
82
    }
83
}
84