Curve   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 11
c 1
b 0
f 0
dl 0
loc 27
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromXML() 0 16 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\XML\dsig11;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\XMLSchema\Exception\{InvalidDOMElementException, MissingElementException, TooManyElementsException};
10
11
use function array_pop;
12
13
/**
14
 * Class representing a dsig11:Curve element.
15
 *
16
 * @package simplesaml/xml-security
17
 */
18
final class Curve extends AbstractCurveType
19
{
20
    /**
21
     * Convert XML into a class instance
22
     *
23
     * @param \DOMElement $xml The XML element we should load
24
     * @return static
25
     *
26
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
27
     *   If the qualified name of the supplied element is wrong
28
     */
29
    public static function fromXML(DOMElement $xml): static
30
    {
31
        Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
32
        Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
33
34
        $a = A::getChildrenOfClass($xml);
35
        Assert::minCount($a, 1, MissingElementException::class);
36
        Assert::maxCount($a, 1, TooManyElementsException::class);
37
38
        $b = B::getChildrenOfClass($xml);
39
        Assert::minCount($b, 1, MissingElementException::class);
40
        Assert::maxCount($b, 1, TooManyElementsException::class);
41
42
        return new static(
43
            array_pop($a),
44
            array_pop($b),
45
        );
46
    }
47
}
48