Issuer::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 38
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

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