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

AbstractAnonymousType   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
c 1
b 0
f 0
dl 0
loc 34
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toXML() 0 6 1
A getValue() 0 3 1
A __construct() 0 3 1
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