SoapAction::toXML()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
c 0
b 0
f 0
rs 10
cc 1
nc 1
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\WSSecurity\Assert\Assert;
9
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10
use SimpleSAML\XML\URIElementTrait;
11
12
/**
13
 * @package simplesamlphp/ws-security
14
 */
15
final class SoapAction extends AbstractWsaElement
16
{
17
    use URIElementTrait;
18
19
20
    /**
21
     * Initialize a wsa:SoapAction
22
     *
23
     * @param string $value
24
     */
25
    public function __construct(string $value)
26
    {
27
        $this->setContent($value);
28
    }
29
30
31
    /**
32
     * Convert XML into a wsa:SoapAction
33
     *
34
     * @param \DOMElement $xml The XML element we should load
35
     * @return static
36
     *
37
     * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
38
     *   If the qualified name of the supplied element is wrong
39
     */
40
    public static function fromXML(DOMElement $xml): static
41
    {
42
        Assert::same($xml->localName, 'SoapAction', InvalidDOMElementException::class);
43
        Assert::same($xml->namespaceURI, SoapAction::NS, InvalidDOMElementException::class);
44
45
        return new static($xml->textContent);
46
    }
47
48
49
    /**
50
     * Convert this element to XML.
51
     *
52
     * @param \DOMElement|null $parent The element we should append this element to.
53
     * @return \DOMElement
54
     */
55
    public function toXML(?DOMElement $parent = null): DOMElement
56
    {
57
        $e = $this->instantiateParentElement($parent);
58
        $e->textContent = $this->getContent();
59
60
        return $e;
61
    }
62
}
63