AbstractAttributeExtensibleString   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toXML() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\WSSecurity\XML\fed;
6
7
use DOMElement;
8
use SimpleSAML\XML\ExtendableAttributesTrait;
9
use SimpleSAML\XML\TypedTextContentTrait;
10
use SimpleSAML\XMLSchema\Type\StringValue;
11
use SimpleSAML\XMLSchema\XML\Constants\NS;
12
13
/**
14
 * An AbstractAttributeExtensibleString element
15
 *
16
 * @package simplesamlphp/ws-security
17
 */
18
abstract class AbstractAttributeExtensibleString extends AbstractFedElement
19
{
20
    use ExtendableAttributesTrait;
21
    use TypedTextContentTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\XML\TypedTextContentTrait requires some properties which are not provided by SimpleSAML\WSSecurity\XM...tributeExtensibleString: $localName, $namespaceURI
Loading history...
22
23
24
    /** @var string */
25
    public const TEXTCONTENT_TYPE = StringValue::class;
26
27
    /** The namespace-attribute for the xs:anyAttribute element */
28
    public const XS_ANY_ATTR_NAMESPACE = NS::OTHER;
29
30
31
    /**
32
     * @param \SimpleSAML\XMLSchema\Type\StringValue $content
33
     * @param \SimpleSAML\XML\Attribute[] $namespacedAttributes
34
     */
35
    public function __construct(StringValue $content, array $namespacedAttributes = [])
36
    {
37
        $this->setContent($content);
38
        $this->setAttributesNS($namespacedAttributes);
39
    }
40
41
42
    /**
43
     * Create XML from this class
44
     *
45
     * @param \DOMElement|null $parent
46
     * @return \DOMElement
47
     */
48
    public function toXML(?DOMElement $parent = null): DOMElement
49
    {
50
        $e = $this->instantiateParentElement($parent);
51
        $e->textContent = $this->getContent()->getValue();
52
53
        foreach ($this->getAttributesNS() as $attr) {
54
            $attr->toXML($e);
55
        }
56
57
        return $e;
58
    }
59
}
60