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
eloc 12
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 1

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