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

UnknownID   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 6
c 3
b 0
f 0
dl 0
loc 42
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getRawIdentifier() 0 3 1
A toXML() 0 3 1
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
    protected 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 unknown 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