Passed
Pull Request — master (#6)
by Tim
02:14
created

AbstractExtensibilityElement   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 6
c 1
b 0
f 0
dl 0
loc 39
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getRequired() 0 3 1
A toXML() 0 9 3
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\WSSecurity\XML\wsdl;
6
7
use DOMElement;
8
9
/**
10
 * Abstract class representing the tExtensibilityElement type.
11
 *
12
 * @package simplesamlphp/ws-security
13
 */
14
abstract class AbstractExtensibilityElement extends AbstractWsdlElement
15
{
16
    /**
17
     * Initialize a wsdl:tExtensibilityElement
18
     *
19
     * @param bool|null $required
20
     */
21
    public function __construct(
22
        protected ?bool $required = null,
23
    ) {
24
    }
25
26
27
    /**
28
     * Collect the value of the required-property.
29
     *
30
     * @return bool|null
31
     */
32
    public function getRequired(): ?bool
33
    {
34
        return $this->required;
35
    }
36
37
38
    /**
39
     * Convert this tExtensibilityElement to XML.
40
     *
41
     * @param \DOMElement|null $parent The element we are converting to XML.
42
     * @return \DOMElement The XML element after adding the data corresponding to this tExtensibilityElement
43
     */
44
    public function toXML(DOMElement $parent = null): DOMElement
45
    {
46
        $e = $this->instantiateParentElement($parent);
47
48
        if ($this->getRequired() !== null) {
49
            $e->setAttribute('required', $this->getRequired() ? 'true' : 'false');
50
        }
51
52
        return $e;
53
    }
54
}
55