Passed
Push — master ( fb3113...2f4a0c )
by Tim
02:23
created

AbstractAttributedQNameType   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A toXML() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\WSSecurity\XML\wsaw;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10
use SimpleSAML\XML\Exception\SchemaViolationException;
11
use SimpleSAML\XML\ExtendableAttributesTrait;
12
use SimpleSAML\XML\QNameElementTrait;
13
use SimpleSAML\XML\XsNamespace as NS;
14
15
/**
16
 * Abstract class defining the AttributedQName type
17
 *
18
 * @package simplesamlphp/ws-security
19
 */
20
abstract class AbstractAttributedQNameType extends AbstractWsawElement
21
{
22
    use ExtendableAttributesTrait;
23
    use QNameElementTrait;
24
25
    /** The namespace-attribute for the xs:anyAttribute element */
26
    public const XS_ANY_ATTR_NAMESPACE = NS::OTHER;
27
28
29
    /**
30
     * AbstractAttributedQNameType constructor
31
     *
32
     * @param string $value
33
     * @param \SimpleSAML\XML\Attribute[] $namespacedAttributes
34
     */
35
    public function __construct(
36
        string $value,
37
        array $namespacedAttributes = [],
38
    ) {
39
        $this->setContent($value);
40
        $this->setAttributesNS($namespacedAttributes);
41
    }
42
43
44
    /**
45
     * Convert this AttributedQNameType to XML.
46
     *
47
     * @param \DOMElement|null $parent The element we should append this class to.
48
     * @return \DOMElement The XML element after adding the data corresponding to this AttributedQNameType.
49
     */
50
    public function toXML(DOMElement $parent = null): DOMElement
51
    {
52
        $e = $this->instantiateParentElement($parent);
53
        $e->textContent = $this->getContent();
54
55
        foreach ($this->getAttributesNS() as $attr) {
56
            $attr->toXML($e);
57
        }
58
59
        return $e;
60
    }
61
}
62