Passed
Pull Request — master (#306)
by Tim
03:14
created

UnknownRoleDescriptor::toXML()   A

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 1
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\Assert\Assert;
9
use SimpleSAML\XML\AbstractElement;
10
use SimpleSAML\XML\Chunk;
11
use SimpleSAML\XML\Exception\InvalidDOMElementException;
12
use SimpleSAML\XML\Exception\TooManyElementsException;
13
use SimpleSAML\XML\Utils as XMLUtils;
14
15
use function preg_split;
16
17
/**
18
 * Class representing unknown RoleDescriptors.
19
 *
20
 * @package simplesamlphp/saml2
21
 */
22
final class UnknownRoleDescriptor extends AbstractRoleDescriptor
23
{
24
    /**
25
     * Initialize a saml:RoleDescriptor from scratch.
26
     *
27
     * @param \SimpleSAML\XML\Chunk $chunk The whole RoleDescriptor element as a chunk object.
28
     * @param string $type
29
     * @param string[] $protocolSupportEnumeration A set of URI specifying the protocols supported.
30
     * @param string|null $ID The ID for this document. Defaults to null.
31
     * @param int|null $validUntil Unix time of validity for this document. Defaults to null.
32
     * @param string|null $cacheDuration Maximum time this document can be cached. Defaults to null.
33
     * @param \SimpleSAML\SAML2\XML\md\Extensions|null $extensions An Extensions object. Defaults to null.
34
     * @param string|null $errorURL An URI where to redirect users for support. Defaults to null.
35
     * @param \SimpleSAML\SAML2\XML\md\KeyDescriptor[] $keyDescriptors An array of KeyDescriptor elements. Defaults to an empty array.
36
     * @param \SimpleSAML\SAML2\XML\md\Organization|null $organization The organization running this entity. Defaults to null.
37
     * @param \SimpleSAML\SAML2\XML\md\ContactPerson[] $contacts An array of contacts for this entity. Defaults to an empty array.
38
     * @param \DOMAttr[] $namespacedAttributes
39
     */
40
    protected function __construct(
41
        protected Chunk $chunk,
42
        string $type,
43
        array $protocolSupportEnumeration,
44
        ?string $ID = null,
45
        ?int $validUntil = null,
46
        ?string $cacheDuration = null,
47
        ?Extensions $extensions = null,
48
        ?string $errorURL = null,
49
        array $keyDescriptors = [],
50
        ?Organization $organization = null,
51
        array $contacts = [],
52
        array $namespacedAttributes = []
53
    ) {
54
        parent::__construct(
55
            $type,
56
            $protocolSupportEnumeration,
57
            $ID,
58
            $validUntil,
59
            $cacheDuration,
60
            $extensions,
61
            $errorURL,
62
            $keyDescriptors,
63
            $organization,
64
            $contacts,
65
            $namespacedAttributes
66
        );
67
    }
68
69
70
    /**
71
     * Get the raw version of this RoleDescriptor as a Chunk.
72
     *
73
     * @return \SimpleSAML\XML\Chunk
74
     */
75
    public function getRawRoleDescriptor(): Chunk
76
    {
77
        return $this->chunk;
78
    }
79
80
81
    /**
82
     * Convert this RoleDescriptor to XML.
83
     *
84
     * @param \DOMElement|null $parent The element we are converting to XML.
85
     * @return \DOMElement The XML element after adding the data corresponding to this unknown RoleDescriptor.
86
     */
87
    public function toXML(DOMElement $parent = null): DOMElement
88
    {
89
        return $this->getRawRoleDescriptor()->toXML($parent);
90
    }
91
}
92