ProblemAction   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 14
dl 0
loc 35
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromXML() 0 22 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\Exception\TooManyElementsException;
11
use SimpleSAML\XML\{SchemaValidatableElementInterface, SchemaValidatableElementTrait};
12
13
use function array_pop;
14
15
/**
16
 * A ProblemAction
17
 *
18
 * @package simplesamlphp/ws-security
19
 */
20
final class ProblemAction extends AbstractProblemActionType implements SchemaValidatableElementInterface
21
{
22
    use SchemaValidatableElementTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\XML\SchemaValidatableElementTrait requires some properties which are not provided by SimpleSAML\WSSecurity\XML\wsa_200508\ProblemAction: $message, $line
Loading history...
23
24
    /**
25
     * Convert XML into a class instance
26
     *
27
     * @param \DOMElement $xml The XML element we should load
28
     * @return static
29
     *
30
     * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
31
     *   If the qualified name of the supplied element is wrong
32
     */
33
    public static function fromXML(DOMElement $xml): static
34
    {
35
        Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
36
        Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
37
38
        $action = Action::getChildrenOfClass($xml);
39
        Assert::maxCount(
40
            $action,
41
            1,
42
            'No more than one Action element allowed in <wsa:ProblemAction>.',
43
            TooManyElementsException::class,
44
        );
45
46
        $soapAction = SoapAction::getChildrenOfClass($xml);
47
        Assert::maxCount(
48
            $soapAction,
49
            1,
50
            'No more than one SoapAction element allowed in <wsa:ProblemAction>.',
51
            TooManyElementsException::class,
52
        );
53
54
        return new static(array_pop($action), array_pop($soapAction), self::getAttributesNSFromXML($xml));
55
    }
56
}
57