Passed
Push — master ( fb3113...2f4a0c )
by Tim
02:23
created

AbstractAnonymousType::getValue()   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\WSSecurity\XML\wsaw;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10
use SimpleSAML\XML\Exception\SchemaViolationException;
11
use ValueError;
12
13
use function sprintf;
14
15
/**
16
 * Abstract class defining the Anonymous type
17
 *
18
 * @package simplesamlphp/ws-security
19
 */
20
abstract class AbstractAnonymousType extends AbstractWsawElement
21
{
22
    /**
23
     * AbstractAnonymousType constructor
24
     *
25
     * @param \SimpleSAML\WSSecurity\XML\wsaw\AnonymousEnum $value
26
     */
27
    public function __construct(
28
        protected AnonymousEnum $value,
29
    ) {
30
    }
31
32
33
    /**
34
     * @return \SimpleSAML\WSSecurity\XML\wsaw\AnonymousEnum
35
     */
36
    public function getValue(): AnonymousEnum
37
    {
38
        return $this->value;
39
    }
40
41
42
    /**
43
     * Convert this Anomymous to XML.
44
     *
45
     * @param \DOMElement|null $parent The element we should append this class to.
46
     * @return \DOMElement The XML element after adding the data corresponding to this Anonymous.
47
     */
48
    public function toXML(DOMElement $parent = null): DOMElement
49
    {
50
        $e = $this->instantiateParentElement($parent);
51
        $e->textContent = $this->getValue()->value;
52
53
        return $e;
54
    }
55
}
56