Passed
Pull Request — master (#305)
by Jaime Pérez
02:15
created

UnknownID::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 4
dl 0
loc 8
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\saml;
6
7
use DOMElement;
8
use SimpleSAML\XML\Chunk;
9
10
/**
11
 * Class for unknown identifiers.
12
 *
13
 * @package simplesamlphp/saml2
14
 */
15
final class UnknownID extends AbstractBaseID
16
{
17
    /** @var \SimpleSAML\XML\Chunk */
18
    private Chunk $chunk;
19
20
    /**
21
     * @param \SimpleSAML\XML\Chunk $chunk The whole BaseID element as a chunk object.
22
     * @param string $type The xsi:type of this identifier.
23
     * @param string|null $NameQualifier
24
     * @param string|null $SPNameQualifier
25
     */
26
    public function __construct(
27
        Chunk $chunk,
28
        string $type,
29
        ?string $NameQualifier = null,
30
        ?string $SPNameQualifier = null
31
    ) {
32
        parent::__construct($type, $NameQualifier, $SPNameQualifier);
33
        $this->chunk = $chunk;
34
    }
35
36
37
    /**
38
     * Get the raw version of this identifier as a Chunk
39
     *
40
     * @return \SimpleSAML\XML\Chunk
41
     */
42
    public function getRawIdentifier(): Chunk
43
    {
44
        return $this->chunk;
45
    }
46
47
48
    /**
49
     * Convert this custom ID to XML.
50
     *
51
     * @param \DOMElement|null $parent The element we are converting to XML.
52
     * @return \DOMElement The XML element after adding the data corresponding to this unknown ID.
53
     */
54
    public function toXML(DOMElement $parent = null): DOMElement
55
    {
56
        return $this->chunk->toXML($parent);
57
    }
58
}
59