Issues (36)

src/CAS/XML/AbstractAttributes.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\CAS\XML;
6
7
use DOMElement;
8
use SimpleSAML\CAS\Constants as C;
9
use SimpleSAML\XML\ExtendableElementTrait;
10
use SimpleSAML\XMLSchema\XML\Constants\NS;
11
12
/**
13
 * Class for CAS attributes
14
 *
15
 * @package simplesamlphp/xml-cas
16
 */
17
abstract class AbstractAttributes extends AbstractCasElement
18
{
19
    use ExtendableElementTrait;
20
21
22
    final public const string LOCALNAME = 'attributes';
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 22 at column 30
Loading history...
23
24
    /** The namespace-attribute for the xs:any element */
25
    final public const string XS_ANY_ELT_NAMESPACE = NS::ANY;
26
27
    /** The exclusions for the xs:any element */
28
    final public const array XS_ANY_ELT_EXCLUSIONS = [
29
        [C::NS_CAS, 'authenticationDate'],
30
        [C::NS_CAS, 'longTermAuthenticationRequestTokenUsed'],
31
        [C::NS_CAS, 'isFromNewLogin'],
32
    ];
33
34
35
    /**
36
     * Initialize a cas:attributes element
37
     *
38
     * @param \SimpleSAML\CAS\XML\AuthenticationDate $authenticationDate
39
     * @param \SimpleSAML\CAS\XML\LongTermAuthenticationRequestTokenUsed $longTermAuthenticationRequestTokenUsed
40
     * @param \SimpleSAML\CAS\XML\IsFromNewLogin $isFromNewLogin
41
     * @param list<\SimpleSAML\XML\SerializableElementInterface> $elts
42
     */
43
    public function __construct(
44
        protected AuthenticationDate $authenticationDate,
45
        protected LongTermAuthenticationRequestTokenUsed $longTermAuthenticationRequestTokenUsed,
46
        protected IsFromNewLogin $isFromNewLogin,
47
        array $elts = [],
48
    ) {
49
        $this->setElements($elts);
50
    }
51
52
53
    /**
54
     * @return \SimpleSAML\CAS\XML\AuthenticationDate
55
     */
56
    public function getAuthenticationDate(): AuthenticationDate
57
    {
58
        return $this->authenticationDate;
59
    }
60
61
62
    /**
63
     * @return \SimpleSAML\CAS\XML\LongTermAuthenticationRequestTokenUsed
64
     */
65
    public function getLongTermAuthenticationRequestTokenUsed(): LongTermAuthenticationRequestTokenUsed
66
    {
67
        return $this->longTermAuthenticationRequestTokenUsed;
68
    }
69
70
71
    /**
72
     * @return \SimpleSAML\CAS\XML\IsFromNewLogin
73
     */
74
    public function getIsFromNewLogin(): IsFromNewLogin
75
    {
76
        return $this->isFromNewLogin;
77
    }
78
79
80
    /**
81
     * Convert this Attributes to XML.
82
     *
83
     * @param \DOMElement|null $parent The element we should append this Attributes to.
84
     * @return \DOMElement
85
     */
86
    public function toXML(?DOMElement $parent = null): DOMElement
87
    {
88
        $e = $this->instantiateParentElement($parent);
89
90
        $this->getAuthenticationDate()->toXML($e);
91
        $this->getLongTermAuthenticationRequestTokenUsed()->toXML($e);
92
        $this->getIsFromNewLogin()->toXML($e);
93
94
        foreach ($this->elements as $elt) {
95
            if (!$elt->isEmptyElement()) {
96
                $elt->toXML($e);
97
            }
98
        }
99
100
        return $e;
101
    }
102
}
103