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

AbstractServiceResponse::toXML()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\CAS\XML;
6
7
use DOMElement;
8
9
/**
10
 * Class for CAS serviceResponse
11
 *
12
 * @package simplesamlphp/xml-cas
13
 */
14
abstract class AbstractServiceResponse extends AbstractCasElement
15
{
16
    /** @var string */
17
    final public const LOCALNAME = 'serviceResponse';
18
19
20
    /**
21
     * Initialize a cas:serviceResponse element
22
     *
23
     * @param \SimpleSAML\CAS\XML\AbstractResponse $response
24
     */
25
    public function __construct(
26
        protected AbstractResponse $response,
27
    ) {
28
    }
29
30
31
    /**
32
     * @return \SimpleSAML\CAS\XML\AbstractResponse
33
     */
34
    public function getResponse(): AbstractResponse
35
    {
36
        return $this->response;
37
    }
38
39
40
    /**
41
     * Convert this ServiceResponse to XML.
42
     *
43
     * @param \DOMElement|null $parent The element we should append this ServiceResponse to.
44
     * @return \DOMElement
45
     */
46
    public function toXML(?DOMElement $parent = null): DOMElement
47
    {
48
        $e = $this->instantiateParentElement($parent);
49
50
        $this->getResponse()->toXML($e);
51
52
        return $e;
53
    }
54
}
55