Passed
Branch feature/php83 (cb5cde)
by Tim
14:20
created

DiscoveryResponse   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\idpdisc;
6
7
use SimpleSAML\SAML2\Assert\Assert;
8
use SimpleSAML\SAML2\Constants as C;
9
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
10
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
11
use SimpleSAML\SAML2\XML\md\AbstractIndexedEndpointType;
12
use SimpleSAML\XML\SchemaValidatableElementInterface;
13
use SimpleSAML\XML\SchemaValidatableElementTrait;
14
use SimpleSAML\XMLSchema\Type\BooleanValue;
15
use SimpleSAML\XMLSchema\Type\UnsignedShortValue;
16
17
/**
18
 * Abstract class to be implemented by all the classes in this namespace
19
 *
20
 * @package simplesamlphp/saml2
21
 *
22
 * @see http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-idp-discovery.html
23
 */
24
final class DiscoveryResponse extends AbstractIndexedEndpointType implements SchemaValidatableElementInterface
25
{
26
    use SchemaValidatableElementTrait;
27
28
29
    public const string NS = C::NS_IDPDISC;
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 29 at column 24
Loading history...
30
31
    public const string NS_PREFIX = 'idpdisc';
32
33
    public const string 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 \SimpleSAML\XMLSchema\Type\UnsignedShortValue $index
42
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue $binding
43
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue $location
44
     * @param \SimpleSAML\XMLSchema\Type\BooleanValue|null $isDefault
45
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $responseLocation
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
        UnsignedShortValue $index,
53
        SAMLAnyURIValue $binding,
54
        SAMLAnyURIValue $location,
55
        ?BooleanValue $isDefault = null,
56
        ?SAMLAnyURIValue $responseLocation = null, // unused
57
        array $children = [],
58
        array $attributes = [],
59
    ) {
60
        Assert::same($binding->getValue(), C::BINDING_IDPDISC, ProtocolViolationException::class);
61
        Assert::null(
62
            $responseLocation,
63
            'The \'ResponseLocation\' attribute must be omitted for idpdisc:DiscoveryResponse.',
64
        );
65
        parent::__construct($index, $binding, $location, $isDefault, null, $children, $attributes);
66
    }
67
}
68