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

AbstractBindingOperationFault::getName()   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\wsdl;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\XML\Exception\SchemaViolationException;
10
11
/**
12
 * Abstract class representing the tBindingOperationFault type.
13
 *
14
 * @package simplesamlphp/ws-security
15
 */
16
abstract class AbstractBindingOperationFault extends AbstractExtensibleDocumented
17
{
18
    /**
19
     * Initialize a wsdl:tBindingOperationFault
20
     *
21
     * @param string $name
22
     * @param \SimpleSAML\XML\Chunk[] $elements
23
     */
24
    public function __construct(
25
        protected string $name,
26
        array $elements = [],
27
    ) {
28
        Assert::validNCName($name, SchemaViolationException::class);
29
        parent::__construct($elements);
30
    }
31
32
33
    /**
34
     * Collect the value of the name-property.
35
     *
36
     * @return string
37
     */
38
    public function getName(): string
39
    {
40
        return $this->name;
41
    }
42
43
44
    /**
45
     * Test if an object, at the state it's in, would produce an empty XML-element
46
     *
47
     * @return bool
48
     */
49
    public function isEmptyElement(): bool
50
    {
51
        // Upstream abstract elements can be empty, but this one cannot
52
        return false;
53
    }
54
55
56
    /**
57
     * Convert this tBindingOperationFault to XML.
58
     *
59
     * @param \DOMElement|null $parent The element we are converting to XML.
60
     * @return \DOMElement The XML element after adding the data corresponding to this tBindingOperationFault.
61
     */
62
    public function toXML(DOMElement $parent = null): DOMElement
63
    {
64
        $e = parent::toXML($parent);
65
        $e->setAttribute('name', $this->getName());
66
67
        return $e;
68
    }
69
}
70