AbstractSSODescriptor::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 46
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 27
nc 1
nop 13
dl 0
loc 46
rs 9.488
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\md;
6
7
use DOMElement;
8
use SimpleSAML\SAML2\Assert\Assert;
9
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
10
use SimpleSAML\SAML2\Type\SAMLAnyURIListValue;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\SAML2\Type\SAMLAnyURIListValue was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
12
use SimpleSAML\SAML2\Type\SAMLDateTimeValue;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\SAML2\Type\SAMLDateTimeValue was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use SimpleSAML\XML\Constants as C;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XML\Constants was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use SimpleSAML\XMLSchema\Type\DurationValue;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSchema\Type\DurationValue was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use SimpleSAML\XMLSchema\Type\IDValue;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSchema\Type\IDValue was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
17
/**
18
 * Class representing SAML 2 SSODescriptorType.
19
 *
20
 * @package simplesamlphp/saml2
21
 */
22
abstract class AbstractSSODescriptor extends AbstractRoleDescriptorType
0 ignored issues
show
Bug introduced by
The type SimpleSAML\SAML2\XML\md\AbstractRoleDescriptorType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
{
24
    /**
25
     * Initialize a RoleDescriptor.
26
     *
27
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIListValue $protocolSupportEnumeration
28
     *   A set of URI specifying the protocols supported.
29
     * @param \SimpleSAML\XMLSchema\Type\IDValue|null $ID The ID for this document. Defaults to null.
30
     * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $validUntil Unix time of validity for this document.
31
     *   Defaults to null.
32
     * @param \SimpleSAML\XMLSchema\Type\DurationValue|null $cacheDuration Maximum time this document can be cached.
33
     *   Defaults to null.
34
     * @param \SimpleSAML\SAML2\XML\md\Extensions|null $extensions An array of extensions. Defaults to an empty array.
35
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $errorURL An URI where to redirect users for support.
36
     *   Defaults to null.
37
     * @param \SimpleSAML\SAML2\XML\md\KeyDescriptor[] $keyDescriptors An array of KeyDescriptor elements.
38
     *   Defaults to an empty array.
39
     * @param \SimpleSAML\SAML2\XML\md\Organization|null $organization
40
     *   The organization running this entity. Defaults to null.
41
     * @param \SimpleSAML\SAML2\XML\md\ContactPerson[] $contacts An array of contacts for this entity.
42
     *   Defaults to an empty array.
43
     * @param \SimpleSAML\SAML2\XML\md\AbstractIndexedEndpointType[] $artifactResolutionService An array of
44
     *   ArtifactResolutionEndpoint. Defaults to an empty array.
45
     * @param \SimpleSAML\SAML2\XML\md\AbstractEndpointType[] $singleLogoutService An array of SingleLogoutEndpoint.
46
     *   Defaults to an empty array.
47
     * @param \SimpleSAML\SAML2\XML\md\AbstractEndpointType[] $manageNameIDService An array of ManageNameIDService.
48
     *   Defaults to an empty array.
49
     * @param \SimpleSAML\SAML2\XML\md\NameIDFormat[] $nameIDFormat An array of supported NameID formats.
50
     *   Defaults to an empty array.
51
     */
52
    public function __construct(
53
        SAMLAnyURIListValue $protocolSupportEnumeration,
54
        ?IDValue $ID = null,
55
        ?SAMLDateTimeValue $validUntil = null,
56
        ?DurationValue $cacheDuration = null,
57
        ?Extensions $extensions = null,
0 ignored issues
show
Bug introduced by
The type SimpleSAML\SAML2\XML\md\Extensions was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
58
        ?SAMLAnyURIValue $errorURL = null,
59
        array $keyDescriptors = [],
60
        ?Organization $organization = null,
61
        array $contacts = [],
62
        protected array $artifactResolutionService = [],
63
        protected array $singleLogoutService = [],
64
        protected array $manageNameIDService = [],
65
        protected array $nameIDFormat = [],
66
    ) {
67
        Assert::maxCount($artifactResolutionService, C::UNBOUNDED_LIMIT);
68
        Assert::allIsInstanceOf(
69
            $artifactResolutionService,
70
            ArtifactResolutionService::class,
71
            'All md:ArtifactResolutionService endpoints must be an instance of ArtifactResolutionService.',
72
        );
73
        Assert::maxCount($singleLogoutService, C::UNBOUNDED_LIMIT);
74
        Assert::allIsInstanceOf(
75
            $singleLogoutService,
76
            SingleLogoutService::class,
77
            'All md:SingleLogoutService endpoints must be an instance of SingleLogoutService.',
78
        );
79
        Assert::maxCount($manageNameIDService, C::UNBOUNDED_LIMIT);
80
        Assert::allIsInstanceOf(
81
            $manageNameIDService,
82
            ManageNameIDService::class,
83
            'All md:ManageNameIDService endpoints must be an instance of ManageNameIDService.',
84
        );
85
        Assert::maxCount($nameIDFormat, C::UNBOUNDED_LIMIT);
86
        Assert::allIsInstanceOf($nameIDFormat, NameIDFormat::class, ProtocolViolationException::class);
0 ignored issues
show
Bug introduced by
The type SimpleSAML\SAML2\XML\md\NameIDFormat was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
87
88
        parent::__construct(
89
            $protocolSupportEnumeration,
90
            $ID,
91
            $validUntil,
92
            $cacheDuration,
93
            $extensions,
94
            $errorURL,
95
            $keyDescriptors,
96
            $organization,
97
            $contacts,
98
        );
99
    }
100
101
102
    /**
103
     * Collect the value of the ArtifactResolutionService-property
104
     *
105
     * @return \SimpleSAML\SAML2\XML\md\AbstractIndexedEndpointType[]
106
     */
107
    public function getArtifactResolutionService(): array
108
    {
109
        return $this->artifactResolutionService;
110
    }
111
112
113
    /**
114
     * Collect the value of the SingleLogoutService-property
115
     *
116
     * @return \SimpleSAML\SAML2\XML\md\AbstractEndpointType[]
117
     */
118
    public function getSingleLogoutService(): array
119
    {
120
        return $this->singleLogoutService;
121
    }
122
123
124
    /**
125
     * Collect the value of the ManageNameIDService-property
126
     *
127
     * @return \SimpleSAML\SAML2\XML\md\AbstractEndpointType[]
128
     */
129
    public function getManageNameIDService(): array
130
    {
131
        return $this->manageNameIDService;
132
    }
133
134
135
    /**
136
     * Collect the value of the NameIDFormat-property
137
     *
138
     * @return \SimpleSAML\SAML2\XML\md\NameIDFormat[]
139
     */
140
    public function getNameIDFormat(): array
141
    {
142
        return $this->nameIDFormat;
143
    }
144
145
146
    /**
147
     * Add this SSODescriptorType to an EntityDescriptor.
148
     */
149
    public function toUnsignedXML(?DOMElement $parent = null): DOMElement
150
    {
151
        $e = parent::toUnsignedXML($parent);
152
153
        foreach ($this->getArtifactResolutionService() as $ep) {
154
            $ep->toXML($e);
155
        }
156
157
        foreach ($this->getSingleLogoutService() as $ep) {
158
            $ep->toXML($e);
159
        }
160
161
        foreach ($this->getManageNameIDService() as $ep) {
162
            $ep->toXML($e);
163
        }
164
165
        foreach ($this->getNameIDFormat() as $nidFormat) {
166
            $nidFormat->toXML($e);
167
        }
168
169
        return $e;
170
    }
171
}
172