Passed
Pull Request — master (#24)
by Tim
01:55
created

AbstractAuthenticationSuccess::getAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\CAS\XML;
6
7
use DOMElement;
8
9
/**
10
 * Class for CAS authenticationSuccess
11
 *
12
 * @package simplesamlphp/xml-cas
13
 */
14
abstract class AbstractAuthenticationSuccess extends AbstractResponse
15
{
16
    /** @var string */
17
    final public const LOCALNAME = 'authenticationSuccess';
18
19
20
    /**
21
     * Initialize a cas:authenticationSuccess element
22
     *
23
     * @param \SimpleSAML\CAS\XML\User $user
24
     * @param \SimpleSAML\CAS\XML\AbstractAttributes $attributes
25
     * @param \SimpleSAML\CAS\XML\ProxyGrantingTicket|null $proxyGrantingTicket
26
     * @param \SimpleSAML\CAS\XML\Proxies|null $proxies
27
     */
28
    public function __construct(
29
        protected User $user,
30
        protected AbstractAttributes $attributes,
31
        protected ?ProxyGrantingTicket $proxyGrantingTicket = null,
32
        protected ?Proxies $proxies = null,
33
    ) {
34
    }
35
36
37
    /**
38
     * @return \SimpleSAML\CAS\XML\User
39
     */
40
    public function getUser(): User
41
    {
42
        return $this->user;
43
    }
44
45
46
    /**
47
     * @return \SimpleSAML\CAS\XML\AbstractAttributes
48
     */
49
    public function getAttributes(): AbstractAttributes
50
    {
51
        return $this->attributes;
52
    }
53
54
55
    /**
56
     * @return \SimpleSAML\CAS\XML\ProxyGrantingTicket
57
     */
58
    public function getProxyGrantingTicket(): ?ProxyGrantingTicket
59
    {
60
        return $this->proxyGrantingTicket;
61
    }
62
63
64
    /**
65
     * @return \SimpleSAML\CAS\XML\Proxies
66
     */
67
    public function getProxies(): ?Proxies
68
    {
69
        return $this->proxies;
70
    }
71
72
73
    /**
74
     * Convert this AuthenticationSuccess to XML.
75
     *
76
     * @param \DOMElement|null $parent The element we should append this AuthenticationSuccess to.
77
     * @return \DOMElement
78
     */
79
    public function toXML(?DOMElement $parent = null): DOMElement
80
    {
81
        $e = $this->instantiateParentElement($parent);
82
83
        $this->getUser()->toXML($e);
84
        $this->getAttributes()->toXML($e);
85
        $this->getProxyGrantingTicket()?->toXML($e);
86
        $this->getProxies()?->toXML($e);
87
88
        return $e;
89
    }
90
}
91