InclusiveNamespaces::toXML()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 2
b 0
f 0
nc 2
nop 1
dl 0
loc 9
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\XML\ec;
6
7
use DOMElement;
8
use SimpleSAML\XML\SchemaValidatableElementInterface;
9
use SimpleSAML\XML\SchemaValidatableElementTrait;
10
use SimpleSAML\XMLSchema\Type\NMTokensValue;
11
12
use function strval;
13
14
/**
15
 * Class implementing InclusiveNamespaces
16
 *
17
 * @package simplesamlphp/xml-security
18
 */
19
class InclusiveNamespaces extends AbstractEcElement implements SchemaValidatableElementInterface
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSecurity\XML\ec\AbstractEcElement 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...
20
{
21
    use SchemaValidatableElementTrait;
22
23
24
    /**
25
     * Initialize the InclusiveNamespaces element.
26
     *
27
     * @param \SimpleSAML\XMLSchema\Type\NMTokensValue|null $prefixes
28
     */
29
    final public function __construct(
30
        protected ?NMTokensValue $prefixes,
31
    ) {
32
    }
33
34
35
    /**
36
     * Get the prefixes specified by this element.
37
     *
38
     * @return \SimpleSAML\XMLSchema\Type\NMTokensValue|null
39
     */
40
    public function getPrefixes(): ?NMTokensValue
41
    {
42
        return $this->prefixes;
43
    }
44
45
46
    /**
47
     * Convert XML into an InclusiveNamespaces element.
48
     *
49
     * @param \DOMElement $xml The XML element we should load.
50
     */
51
    public static function fromXML(DOMElement $xml): static
52
    {
53
        return new static(
54
            self::getOptionalAttribute($xml, 'PrefixList', NMTokensValue::class, null),
55
        );
56
    }
57
58
59
    /**
60
     * Convert this InclusiveNamespaces to XML.
61
     *
62
     * @param \DOMElement|null $parent The element we should append this InclusiveNamespaces to.
63
     */
64
    public function toXML(?DOMElement $parent = null): DOMElement
65
    {
66
        $e = $this->instantiateParentElement($parent);
67
68
        if ($this->getPrefixes() !== null) {
69
            $e->setAttribute('PrefixList', strval($this->getPrefixes()));
70
        }
71
72
        return $e;
73
    }
74
}
75