Passed
Push — master ( c6f9d9...f007cf )
by Marek
02:20
created

EidasSPType::toXML()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 8
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace OMSAML2\Chunks;
4
5
use DOMElement;
6
use SAML2\XML\Chunk;
7
8
class EidasSPType extends Chunk
9
{
10
    const NS_EIDAS = 'http://eidas.europa.eu/saml-extensions';
11
    const LOCAL_NAME = 'SPType';
12
    public $sptype = 'public';
13
14
    public function __construct(?DOMElement $xml = null)
15
    {
16
        if (!empty($xml)) {
17
            parent::__construct($xml);
18
            $this->sptype = $xml->nodeValue;
19
        }
20
    }
21
22
    public function toXML(DOMElement $parent): DOMElement
23
    {
24
        $sptype = $parent->ownerDocument->createElementNS(self::NS_EIDAS, self::LOCAL_NAME);
25
        $sptype->nodeValue = $this->sptype;
26
27
        $parent->appendChild($sptype);
28
29
        return $sptype;
30
    }
31
}