AdditionalMetadataLocation::getLocation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\md;
6
7
use DOMElement;
8
use SimpleSAML\SAML2\Assert\Assert;
9
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
10
use SimpleSAML\XML\SchemaValidatableElementInterface;
11
use SimpleSAML\XML\SchemaValidatableElementTrait;
12
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
13
14
/**
15
 * Class representing SAML 2 metadata AdditionalMetadataLocation element.
16
 *
17
 * @package simplesamlphp/saml2
18
 */
19
final class AdditionalMetadataLocation extends AbstractMdElement implements SchemaValidatableElementInterface
0 ignored issues
show
Bug introduced by
The type SimpleSAML\SAML2\XML\md\AbstractMdElement 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
     * Create a new instance of AdditionalMetadataLocation
26
     *
27
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue $namespace
28
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue $location
29
     */
30
    public function __construct(
31
        protected SAMLAnyURIValue $namespace,
32
        protected SAMLAnyURIValue $location,
33
    ) {
34
    }
35
36
37
    /**
38
     * Collect the value of the namespace-property
39
     *
40
     * @return \SimpleSAML\SAML2\Type\SAMLAnyURIValue
41
     */
42
    public function getNamespace(): SAMLAnyURIValue
43
    {
44
        return $this->namespace;
45
    }
46
47
48
    /**
49
     * Collect the value of the location-property
50
     *
51
     * @return \SimpleSAML\SAML2\Type\SAMLAnyURIValue
52
     */
53
    public function getLocation(): SAMLAnyURIValue
54
    {
55
        return $this->location;
56
    }
57
58
59
    /**
60
     * Initialize an AdditionalMetadataLocation element.
61
     *
62
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
63
     *   if the qualified name of the supplied element is wrong
64
     * @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException
65
     *   if the supplied element is missing any of the mandatory attributes
66
     */
67
    public static function fromXML(DOMElement $xml): static
68
    {
69
        Assert::same($xml->localName, 'AdditionalMetadataLocation', InvalidDOMElementException::class);
70
        Assert::same($xml->namespaceURI, AdditionalMetadataLocation::NS, InvalidDOMElementException::class);
71
72
        return new static(
73
            self::getAttribute($xml, 'namespace', SAMLAnyURIValue::class),
74
            SAMLAnyURIValue::fromString($xml->textContent),
75
        );
76
    }
77
78
79
    /**
80
     * Convert this AdditionalMetadataLocation to XML.
81
     */
82
    public function toXML(?DOMElement $parent = null): DOMElement
83
    {
84
        $e = $this->instantiateParentElement($parent);
85
        $e->textContent = $this->getLocation()->getValue();
86
        $e->setAttribute('namespace', $this->getNamespace()->getValue());
87
88
        return $e;
89
    }
90
}
91