DiscoveryResponse   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 1
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
    /** @var string */
26
    public const NS = C::NS_IDPDISC;
27
28
    /** @var string */
29
    public const NS_PREFIX = 'idpdisc';
30
31
    /** @var string */
32
    public const SCHEMA = 'resources/schemas/sstc-saml-idp-discovery.xsd';
33
34
    /**
35
     * DiscoveryResponse constructor.
36
     *
37
     * This is an endpoint with one restriction: it cannot contain a ResponseLocation.
38
     *
39
     * @param int $index
40
     * @param string $binding
41
     * @param string $location
42
     * @param bool|null $isDefault
43
     * @param string|null $unused
44
     * @param array<\SimpleSAML\XML\SerializableElementInterface> $children
45
     * @param array<\SimpleSAML\XML\Attribute> $attributes
46
     *
47
     * @throws \SimpleSAML\Assert\AssertionFailedException
48
     */
49
    public function __construct(
50
        int $index,
51
        string $binding,
52
        string $location,
53
        ?bool $isDefault = null,
54
        ?string $unused = null,
55
        array $children = [],
56
        array $attributes = [],
57
    ) {
58
        Assert::same($binding, C::BINDING_IDPDISC, ProtocolViolationException::class);
59
        Assert::null(
60
            $unused,
61
            'The \'ResponseLocation\' attribute must be omitted for idpdisc:DiscoveryResponse.',
62
        );
63
        parent::__construct($index, C::BINDING_IDPDISC, $location, $isDefault, null, $children, $attributes);
64
    }
65
}
66