ECParameters   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromXML() 0 34 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;
10
use SimpleSAML\XMLSchema\Exception\MissingElementException;
11
use SimpleSAML\XMLSchema\Exception\TooManyElementsException;
12
13
use function array_pop;
14
15
/**
16
 * Class representing a dsig11:ECParameters element.
17
 *
18
 * @package simplesaml/xml-security
19
 */
20
final class ECParameters extends AbstractECParametersType
21
{
22
    /**
23
     * Convert XML into a ECParameters element
24
     *
25
     * @param \DOMElement $xml The XML element we should load
26
     *
27
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
28
     *   If the qualified name of the supplied element is wrong
29
     */
30
    public static function fromXML(DOMElement $xml): static
31
    {
32
        Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
33
        Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class);
34
35
        $fieldId = FieldID::getChildrenOfClass($xml);
36
        Assert::minCount($fieldId, 1, MissingElementException::class);
37
        Assert::maxCount($fieldId, 1, TooManyElementsException::class);
38
39
        $curve = Curve::getChildrenOfClass($xml);
40
        Assert::minCount($curve, 1, MissingElementException::class);
41
        Assert::maxCount($curve, 1, TooManyElementsException::class);
42
43
        $base = Base::getChildrenOfClass($xml);
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSecurity\XML\dsig11\Base 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...
44
        Assert::minCount($base, 1, MissingElementException::class);
45
        Assert::maxCount($base, 1, TooManyElementsException::class);
46
47
        $order = Order::getChildrenOfClass($xml);
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSecurity\XML\dsig11\Order 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...
48
        Assert::minCount($order, 1, MissingElementException::class);
49
        Assert::maxCount($order, 1, TooManyElementsException::class);
50
51
        $coFactor = CoFactor::getChildrenOfClass($xml);
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSecurity\XML\dsig11\CoFactor 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...
52
        Assert::maxCount($coFactor, 1, TooManyElementsException::class);
53
54
        $validationData = ValidationData::getChildrenOfClass($xml);
55
        Assert::maxCount($validationData, 1, TooManyElementsException::class);
56
57
        return new static(
58
            array_pop($fieldId),
59
            array_pop($curve),
60
            array_pop($base),
61
            array_pop($order),
62
            array_pop($coFactor),
63
            array_pop($validationData),
64
        );
65
    }
66
}
67