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

Issuer::fromXML()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 1
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\saml;
6
7
use SimpleSAML\Assert\Assert;
8
use SimpleSAML\SAML2\Constants as C;
9
10
/**
11
 * Class representing the saml:Issuer element.
12
 *
13
 * @package simplesamlphp/saml2
14
 */
15
final class Issuer extends NameIDType
16
{
17
    /**
18
     * Initialize a saml:Issuer
19
     *
20
     * @param string $value
21
     * @param string|null $NameQualifier
22
     * @param string|null $SPNameQualifier
23
     * @param string|null $Format
24
     * @param string|null $SPProvidedID
25
     */
26
    public function __construct(
27
        string $value,
28
        ?string $NameQualifier = null,
29
        ?string $SPNameQualifier = null,
30
        ?string $Format = null,
31
        ?string $SPProvidedID = null,
32
    ) {
33
        /**
34
         * The format of this NameIDType.
35
         *
36
         * Defaults to urn:oasis:names:tc:SAML:2.0:nameid-format:entity:
37
         *
38
         * Indicates that the content of the element is the identifier of an entity that provides SAML-based services
39
         * (such as a SAML authority, requester, or responder) or is a participant in SAML profiles (such as a service
40
         * provider supporting the browser SSO profile). Such an identifier can be used in the <Issuer> element to
41
         * identify the issuer of a SAML request, response, or assertion, or within the <NameID> element to make
42
         * assertions about system entities that can issue SAML requests, responses, and assertions. It can also be
43
         * used in other elements and attributes whose purpose is to identify a system entity in various protocol
44
         * exchanges.
45
         *
46
         * The syntax of such an identifier is a URI of not more than 1024 characters in length. It is RECOMMENDED that
47
         * a system entity use a URL containing its own domain name to identify itself.
48
         *
49
         * @see saml-core-2.0-os
50
         *
51
         * From saml-core-2.0-os 8.3.6, when the entity Format is used: "The NameQualifier, SPNameQualifier, and
52
         * SPProvidedID attributes MUST be omitted."
53
         *
54
         * @var string
55
         */
56
        if ($Format === C::NAMEID_ENTITY || $Format === null) {
57
            Assert::allNull(
58
                [$NameQualifier, $SPNameQualifier, $SPProvidedID],
59
                'Illegal combination of attributes being used',
60
            );
61
        }
62
63
        parent::__construct($value, $NameQualifier, $SPNameQualifier, $Format, $SPProvidedID);
64
    }
65
}
66