AbstractProblemActionType::toXML()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 12
c 0
b 0
f 0
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\WSSecurity\XML\wsa_200508;
6
7
use DOMElement;
8
use SimpleSAML\XML\ExtendableAttributesTrait;
9
use SimpleSAML\XML\XsNamespace as NS;
10
11
/**
12
 * Class representing WS-addressing ProblemActionType.
13
 *
14
 * You can extend the class without extending the constructor. Then you can use the methods available and the class
15
 * will generate an element with the same name as the extending class
16
 * (e.g. \SimpleSAML\WSSecurity\wsa\ProblemAction).
17
 *
18
 * @package simplesamlphp/ws-security
19
 */
20
abstract class AbstractProblemActionType extends AbstractWsaElement
21
{
22
    use ExtendableAttributesTrait;
23
24
    /** The namespace-attribute for the xs:anyAttribute element */
25
    public const XS_ANY_ATTR_NAMESPACE = NS::OTHER;
26
27
28
    /**
29
     * AbstractProblemActionType constructor.
30
     *
31
     * @param \SimpleSAML\WSSecurity\XML\wsa_200508\Action|null $action
32
     * @param \SimpleSAML\WSSecurity\XML\wsa_200508\SoapAction|null $soapAction
33
     * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
0 ignored issues
show
Bug introduced by
The type SimpleSAML\WSSecurity\XML\wsa_200508\list was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
34
     */
35
    final public function __construct(
36
        protected ?Action $action = null,
37
        protected ?SoapAction $soapAction = null,
38
        array $namespacedAttributes = [],
39
    ) {
40
        $this->setAttributesNS($namespacedAttributes);
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
        return empty($this->action) && empty($this->soapAction) && empty($this->namespacedAttributes);
52
    }
53
54
55
    /**
56
     * Convert this element to XML.
57
     *
58
     * @param \DOMElement|null $parent The element we should append this element to.
59
     * @return \DOMElement
60
     */
61
    public function toXML(?DOMElement $parent = null): DOMElement
62
    {
63
        $e = $this->instantiateParentElement($parent);
64
65
        $this->action?->toXML($e);
66
        $this->soapAction?->toXML($e);
67
68
        foreach ($this->getAttributesNS() as $attr) {
69
            $attr->toXML($e);
70
        }
71
72
        return $e;
73
    }
74
}
75