Extensions   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromXML() 0 22 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\samlp;
6
7
use DOMElement;
8
use SimpleSAML\SAML2\Assert\Assert;
9
use SimpleSAML\SAML2\Utils\XPath;
10
use SimpleSAML\SAML2\XML\ExtensionsTrait;
11
use SimpleSAML\XML\Chunk;
12
use SimpleSAML\XML\SchemaValidatableElementInterface;
13
use SimpleSAML\XML\SchemaValidatableElementTrait;
14
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
15
16
/**
17
 * Class for handling SAML2 extensions.
18
 *
19
 * @package simplesamlphp/saml2
20
 */
21
final class Extensions extends AbstractSamlpElement implements SchemaValidatableElementInterface
0 ignored issues
show
Bug introduced by
The type SimpleSAML\SAML2\XML\samlp\AbstractSamlpElement 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...
22
{
23
    use ExtensionsTrait;
24
    use SchemaValidatableElementTrait;
25
26
27
    /**
28
     * Create an Extensions object from its samlp:Extensions XML representation.
29
     *
30
     * For those supported extensions, an object of the corresponding class will be created. The rest will be added
31
     * as a \SimpleSAML\XML\Chunk object.
32
     *
33
     * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
34
     *   if the qualified name of the supplied element is wrong
35
     */
36
    public static function fromXML(DOMElement $xml): static
37
    {
38
        Assert::eq(
39
            $xml->namespaceURI,
40
            self::NS,
41
            'Unknown namespace \'' . strval($xml->namespaceURI) . '\' for Extensions element.',
42
            InvalidDOMElementException::class,
43
        );
44
        Assert::eq(
45
            $xml->localName,
46
            static::getClassName(static::class),
47
            'Invalid Extensions element \'' . $xml->localName . '\'',
48
            InvalidDOMElementException::class,
49
        );
50
        $ret = [];
51
52
        /** @var \DOMElement $node */
53
        foreach (XPath::xpQuery($xml, './*', XPath::getXPath($xml)) as $node) {
54
            $ret[] = new Chunk($node);
55
        }
56
57
        return new static($ret);
58
    }
59
}
60