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

AbstractProxyFailure::getCode()   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
use SimpleSAML\CAS\Type\CodeValue;
9
use SimpleSAML\XML\TypedTextContentTrait;
10
use SimpleSAML\XMLSchema\Type\StringValue;
11
12
/**
13
 * Class for CAS proxyFailure
14
 *
15
 * @package simplesamlphp/xml-cas
16
 */
17
abstract class AbstractProxyFailure extends AbstractResponse
18
{
19
    use TypedTextContentTrait;
20
21
22
    /** @var string */
23
    public const TEXTCONTENT_TYPE = StringValue::class;
24
25
    /** @var string */
26
    final public const LOCALNAME = 'proxyFailure';
27
28
29
    /**
30
     * Create a new instance of ProxyFailure
31
     *
32
     * @param \SimpleSAML\XMLSchema\Type\StringValue $content
33
     * @param \SimpleSAML\CAS\Type\CodeValue $code
34
     */
35
    final public function __construct(
36
        StringValue $content,
37
        protected CodeValue $code,
38
    ) {
39
        $this->setContent($content);
40
    }
41
42
43
    /**
44
     * Collect the value of the code-property
45
     *
46
     * @return \SimpleSAML\CAS\Type\CodeValue
47
     */
48
    public function getCode(): CodeValue
49
    {
50
        return $this->code;
51
    }
52
53
54
    /**
55
     * Convert this ProxyFailure to XML.
56
     *
57
     * @param \DOMElement|null $parent The element we should append to.
58
     * @return \DOMElement This ProxyFailure-element.
59
     */
60
    public function toXML(?DOMElement $parent = null): DOMElement
61
    {
62
        $e = $this->instantiateParentElement($parent);
63
64
        $e->textContent = $this->getContent()->getValue();
65
        $e->setAttribute('code', $this->getCode()->getValue());
66
67
        return $e;
68
    }
69
}
70