Passed
Push — master ( 2d3781...f48916 )
by Tim
11:07 queued 06:44
created

OtherSource   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromXML() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\XML\xenc11;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\XML\Exception\InvalidDOMElementException;
10
use SimpleSAML\XML\Exception\TooManyElementsException;
11
12
use function array_pop;
13
14
/**
15
 * A class implementing the xenc11:OtherSource element.
16
 *
17
 * @package simplesamlphp/xml-security
18
 */
19
final class OtherSource extends AbstractAlgorithmIdentifierType
20
{
21
    /**
22
     * @inheritDoc
23
     *
24
     * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
25
     *   If the qualified name of the supplied element is wrong
26
     */
27
    public static function fromXML(DOMElement $xml): static
28
    {
29
        Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
30
        Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class);
31
32
        $parameter = Parameters::getChildrenOfClass($xml);
33
        Assert::maxCount($parameter, 1, TooManyElementsException::class);
34
35
        return new static(
36
            self::getOptionalAttribute($xml, 'Algorithm', null),
0 ignored issues
show
Bug introduced by
It seems like self::getOptionalAttribu...xml, 'Algorithm', null) can also be of type null; however, parameter $Algorithm of SimpleSAML\XMLSecurity\X...erSource::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

36
            /** @scrutinizer ignore-type */ self::getOptionalAttribute($xml, 'Algorithm', null),
Loading history...
37
            array_pop($parameter),
38
        );
39
    }
40
}
41