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

EidasSPType   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 11
dl 0
loc 22
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A toXML() 0 8 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
}