Passed
Pull Request — master (#64)
by Tim
02:02
created

Prime::fromXML()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
rs 10
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\SchemaValidatableElementInterface;
11
use SimpleSAML\XML\SchemaValidatableElementTrait;
12
13
/**
14
 * Class representing a dsig11:Prime element.
15
 *
16
 * @package simplesaml/xml-security
17
 */
18
final class Prime extends AbstractPrimeFieldParamsType implements SchemaValidatableElementInterface
19
{
20
    use SchemaValidatableElementTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\XML\SchemaValidatableElementTrait requires some properties which are not provided by SimpleSAML\XMLSecurity\XML\dsig11\Prime: $message, $line
Loading history...
21
22
    /**
23
     * Convert XML into a Prime element
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::getNamespaceURI(), InvalidDOMElementException::class);
35
36
        return new static(
37
            P::getChildrenOfClass($xml),
0 ignored issues
show
Bug introduced by
SimpleSAML\XMLSecurity\X...etChildrenOfClass($xml) of type array|array<mixed,Simple...LSecurity\XML\dsig11\P> is incompatible with the type SimpleSAML\XMLSecurity\XML\dsig11\P expected by parameter $p of SimpleSAML\XMLSecurity\X...11\Prime::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

37
            /** @scrutinizer ignore-type */ P::getChildrenOfClass($xml),
Loading history...
38
        );
39
    }
40
}
41