Passed
Push — master ( b6dce4...ad9ad0 )
by Tim
05:37 queued 04:11
created

Issuer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SPID\XML\saml;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\SAML2\Constants as C;
10
use SimpleSAML\SAML2\XML\saml\NameIDType;
11
use SimpleSAML\XML\Exception\InvalidDOMElementException;
12
use SPID\Exception\ProtocolViolationException;
0 ignored issues
show
Bug introduced by
The type SPID\Exception\ProtocolViolationException 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...
13
14
/**
15
 * Class representing the saml:Issuer element compliant with SPID specification.
16
 *
17
 * @package simplesamlphp/saml2-module-spid
18
 */
19
final class Issuer extends NameIDType
20
{
21
    /**
22
     * Initialize a saml:Issuer conforming to SPID specification
23
     *
24
     * @param string $value
25
     * @param string $NameQualifier
26
     */
27
    public function __construct(
28
        string $value,
29
        string $NameQualifier
30
    ) {
31
        parent::__construct($value, $NameQualifier, null, C::NAMEID_ENTITY);
32
    }
33
34
35
    /**
36
     * Convert XML into an Issuer
37
     *
38
     * @param \DOMElement $xml The XML element we should load
39
     *
40
     * @return static
41
     * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
42
     * @throws \SimpleSAML\SPID\Exception\ProtocolViolationException
43
     */
44
    public static function fromXML(DOMElement $xml): static
45
    {
46
        Assert::same($xml->localName, 'Issuer', InvalidDOMElementException::class);
47
        Assert::same($xml->namespaceURI, Issuer::NS, InvalidDOMElementException::class);
48
49
        $format = self::getAttribute($xml, 'Format');
50
        Assert::same($format, C::NAMEID_ENTITY, ProtocolViolationException::class);
51
52
        $nameQualifier = self::getAttribute($xml, 'NameQualifier');
53
        return new static($xml->textContent, $nameQualifier);
54
    }
55
}
56