DiscoveryResponse::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 7
dl 0
loc 15
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\idpdisc;
6
7
use SimpleSAML\Assert\Assert;
8
use SimpleSAML\SAML2\Constants as C;
9
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
10
use SimpleSAML\SAML2\XML\md\AbstractIndexedEndpointType;
11
use SimpleSAML\XML\SchemaValidatableElementInterface;
12
use SimpleSAML\XML\SchemaValidatableElementTrait;
13
14
/**
15
 * Abstract class to be implemented by all the classes in this namespace
16
 *
17
 * @package simplesamlphp/saml2
18
 *
19
 * @see http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-idp-discovery.html
20
 */
21
final class DiscoveryResponse extends AbstractIndexedEndpointType implements SchemaValidatableElementInterface
22
{
23
    use SchemaValidatableElementTrait;
24
25
26
    /** @var string */
27
    public const NS = C::NS_IDPDISC;
28
29
    /** @var string */
30
    public const NS_PREFIX = 'idpdisc';
31
32
    /** @var string */
33
    public const SCHEMA = 'resources/schemas/sstc-saml-idp-discovery.xsd';
34
35
36
    /**
37
     * DiscoveryResponse constructor.
38
     *
39
     * This is an endpoint with one restriction: it cannot contain a ResponseLocation.
40
     *
41
     * @param int $index
42
     * @param string $binding
43
     * @param string $location
44
     * @param bool|null $isDefault
45
     * @param string|null $unused
46
     * @param array<\SimpleSAML\XML\SerializableElementInterface> $children
47
     * @param array<\SimpleSAML\XML\Attribute> $attributes
48
     *
49
     * @throws \SimpleSAML\Assert\AssertionFailedException
50
     */
51
    public function __construct(
52
        int $index,
53
        string $binding,
54
        string $location,
55
        ?bool $isDefault = null,
56
        ?string $unused = null,
57
        array $children = [],
58
        array $attributes = [],
59
    ) {
60
        Assert::same($binding, C::BINDING_IDPDISC, ProtocolViolationException::class);
61
        Assert::null(
62
            $unused,
63
            'The \'ResponseLocation\' attribute must be omitted for idpdisc:DiscoveryResponse.',
64
        );
65
        parent::__construct($index, C::BINDING_IDPDISC, $location, $isDefault, null, $children, $attributes);
66
    }
67
}
68