AbstractAttributeDesignatorType::toXML()   A
last analyzed

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
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML11\XML\saml;
6
7
use DOMElement;
8
use SimpleSAML\SAML11\Type\{SAMLAnyURIValue, SAMLStringValue};
9
10
use function strval;
11
12
/**
13
 * SAML AttributeDesignatorType abstract data type.
14
 *
15
 * @package simplesamlphp/saml11
16
 */
17
abstract class AbstractAttributeDesignatorType extends AbstractSamlElement
18
{
19
    /**
20
     * Initialize a saml:AttributeDesignatorType from scratch
21
     *
22
     * @param \SimpleSAML\SAML11\Type\SAMLStringValue $AttributeName
23
     * @param \SimpleSAML\SAML11\Type\SAMLAnyURIValue $AttributeNamespace
24
     */
25
    public function __construct(
26
        protected SAMLStringValue $AttributeName,
27
        protected SAMLAnyURIValue $AttributeNamespace,
28
    ) {
29
    }
30
31
32
    /**
33
     * Collect the value of the AttributeName-property
34
     *
35
     * @return \SimpleSAML\SAML11\Type\SAMLStringValue
36
     */
37
    public function getAttributeName(): SAMLStringValue
38
    {
39
        return $this->AttributeName;
40
    }
41
42
43
    /**
44
     * Collect the value of the AttributeNamespace-property
45
     *
46
     * @return \SimpleSAML\SAML11\Type\SAMLAnyURIValue
47
     */
48
    public function getAttributeNamespace(): SAMLAnyURIValue
49
    {
50
        return $this->AttributeNamespace;
51
    }
52
53
54
    /**
55
     * Convert this AttributeDesignatorType to XML.
56
     *
57
     * @param \DOMElement $parent The element we are converting to XML.
58
     * @return \DOMElement The XML element after adding the data corresponding to this AttributeDesignatorType.
59
     */
60
    public function toXML(?DOMElement $parent = null): DOMElement
61
    {
62
        $e = $this->instantiateParentElement($parent);
63
64
        $e->setAttribute('AttributeName', strval($this->getAttributeName()));
65
        $e->setAttribute('AttributeNamespace', strval($this->getAttributeNamespace()));
66
67
        return $e;
68
    }
69
}
70