AbstractSecurityTokenServiceType::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 69
Code Lines 38

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 38
c 1
b 0
f 0
dl 0
loc 69
rs 9.312
cc 1
nc 1
nop 24

How to fix   Long Method    Many Parameters   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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\WSSecurity\XML\fed;
6
7
use DOMElement;
8
use SimpleSAML\SAML2\Type\SAMLAnyURIListValue;
9
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
10
use SimpleSAML\SAML2\Type\SAMLDateTimeValue;
11
use SimpleSAML\SAML2\Type\SAMLStringValue;
12
use SimpleSAML\SAML2\XML\md\Extensions;
13
use SimpleSAML\SAML2\XML\md\Organization;
14
use SimpleSAML\WSSecurity\Assert\Assert;
15
use SimpleSAML\WSSecurity\Constants as C;
16
use SimpleSAML\XMLSchema\Exception\MissingElementException;
17
use SimpleSAML\XMLSchema\Exception\SchemaViolationException;
18
use SimpleSAML\XMLSchema\Type\DurationValue;
19
use SimpleSAML\XMLSchema\Type\IDValue;
20
use SimpleSAML\XMLSchema\Type\QNameValue;
21
22
/**
23
 * A SecurityTokenServiceType
24
 *
25
 * @package simplesamlphp/ws-security
26
 */
27
abstract class AbstractSecurityTokenServiceType extends AbstractWebServiceDescriptorType
28
{
29
    /** @var string */
30
    public const XSI_TYPE_PREFIX = 'fed';
31
32
    /** @var string */
33
    public const XSI_TYPE_NAME = 'SecurityTokenServiceType';
34
35
    /** @var string */
36
    public const XSI_TYPE_NAMESPACE = C::NS_FED;
37
38
39
    /**
40
     * SecurityTokenServiceType constructor.
41
     *
42
     * @param \SimpleSAML\XMLSchema\Type\QNameValue $type
43
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIListValue $protocolSupportEnumeration
44
     *   A set of URI specifying the protocols supported.
45
     * @param \SimpleSAML\XMLSchema\Type\IDValue|null $ID The ID for this document. Defaults to null.
46
     * @param \SimpleSAML\SAML2\Type\SAMLDateTimeValue|null $validUntil
47
     *   Unix time of validity for this document. Defaults to null.
48
     * @param \SimpleSAML\XMLSchema\Type\DurationValue|null $cacheDuration
49
     *   Maximum time this document can be cached. Defaults to null.
50
     * @param \SimpleSAML\SAML2\XML\md\Extensions|null $extensions An array of extensions. Defaults to an empty array.
51
     * @param \SimpleSAML\SAML2\Type\SAMLAnyURIValue|null $errorURL
52
     *   An URI where to redirect users for support. Defaults to null.
53
     * @param \SimpleSAML\SAML2\XML\md\KeyDescriptor[] $keyDescriptors An array of KeyDescriptor elements.
54
     *   Defaults to an empty array.
55
     * @param \SimpleSAML\SAML2\XML\md\Organization|null $organization
56
     *   The organization running this entity. Defaults to null.
57
     * @param \SimpleSAML\SAML2\XML\md\ContactPerson[] $contacts An array of contacts for this entity.
58
     *   Defaults to an empty array.
59
     * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
0 ignored issues
show
Bug introduced by
The type SimpleSAML\WSSecurity\XML\fed\list 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...
60
     * @param \SimpleSAML\WSSecurity\XML\fed\LogicalServiceNamesOffered|null $logicalServiceNamesOffered
61
     * @param \SimpleSAML\WSSecurity\XML\fed\TokenTypesOffered|null $tokenTypesOffered
62
     * @param \SimpleSAML\WSSecurity\XML\fed\ClaimDialectsOffered|null $claimDialectsOffered
63
     * @param \SimpleSAML\WSSecurity\XML\fed\ClaimTypesOffered|null $claimTypesOffered
64
     * @param \SimpleSAML\WSSecurity\XML\fed\ClaimTypesRequested|null $claimTypesRequested
65
     * @param \SimpleSAML\WSSecurity\XML\fed\AutomaticPseudonyms|null $automaticPseudonyms
66
     * @param \SimpleSAML\WSSecurity\XML\fed\TargetScopes|null $targetScopes
67
     * @param \SimpleSAML\SAML2\Type\SAMLStringValue|null $serviceDisplayName
68
     * @param \SimpleSAML\SAML2\Type\SAMLStringValue|null $serviceDescription
69
     * @param \SimpleSAML\WSSecurity\XML\fed\SecurityTokenServiceEndpoint[] $securityTokenServiceEndpoint
70
     * @param \SimpleSAML\WSSecurity\XML\fed\SingleSignOutSubscriptionEndpoint[] $singleSignOutSubscriptionEndpoint
71
     * @param \SimpleSAML\WSSecurity\XML\fed\SingleSignOutNotificationEndpoint[] $singleSignOutNotificationEndpoint
72
     * @param \SimpleSAML\WSSecurity\XML\fed\PassiveRequestorEndpoint[] $passiveRequestorEndpoint
73
     */
74
    final public function __construct(
75
        QNameValue $type,
76
        SAMLAnyURIListValue $protocolSupportEnumeration,
77
        ?IDValue $ID = null,
78
        ?SAMLDateTimeValue $validUntil = null,
79
        ?DurationValue $cacheDuration = null,
80
        ?Extensions $extensions = null,
81
        ?SAMLAnyURIValue $errorURL = null,
82
        array $keyDescriptors = [],
83
        ?Organization $organization = null,
84
        array $contacts = [],
85
        array $namespacedAttributes = [],
86
        ?LogicalServiceNamesOffered $logicalServiceNamesOffered = null,
87
        ?TokenTypesOffered $tokenTypesOffered = null,
88
        ?ClaimDialectsOffered $claimDialectsOffered = null,
89
        ?ClaimTypesOffered $claimTypesOffered = null,
90
        ?ClaimTypesRequested $claimTypesRequested = null,
91
        ?AutomaticPseudonyms $automaticPseudonyms = null,
92
        ?TargetScopes $targetScopes = null,
93
        ?SAMLStringValue $serviceDisplayName = null,
94
        ?SAMLStringValue $serviceDescription = null,
95
        protected array $securityTokenServiceEndpoint = [],
96
        protected array $singleSignOutSubscriptionEndpoint = [],
97
        protected array $singleSignOutNotificationEndpoint = [],
98
        protected array $passiveRequestorEndpoint = [],
99
    ) {
100
        Assert::minCount($securityTokenServiceEndpoint, 1, MissingElementException::class);
101
        Assert::allIsInstanceOf(
102
            $securityTokenServiceEndpoint,
103
            SecurityTokenServiceEndpoint::class,
104
            SchemaViolationException::class,
105
        );
106
        Assert::allIsInstanceOf(
107
            $singleSignOutSubscriptionEndpoint,
108
            SingleSignOutSubscriptionEndpoint::class,
109
            SchemaViolationException::class,
110
        );
111
        Assert::allIsInstanceOf(
112
            $singleSignOutNotificationEndpoint,
113
            SingleSignOutNotificationEndpoint::class,
114
            SchemaViolationException::class,
115
        );
116
        Assert::allIsInstanceOf(
117
            $passiveRequestorEndpoint,
118
            PassiveRequestorEndpoint::class,
119
            SchemaViolationException::class,
120
        );
121
122
        parent::__construct(
123
            $type,
124
            $protocolSupportEnumeration,
125
            $ID,
126
            $validUntil,
127
            $cacheDuration,
128
            $extensions,
129
            $errorURL,
130
            $keyDescriptors,
131
            $organization,
132
            $contacts,
133
            $namespacedAttributes,
134
            $logicalServiceNamesOffered,
135
            $tokenTypesOffered,
136
            $claimDialectsOffered,
137
            $claimTypesOffered,
138
            $claimTypesRequested,
139
            $automaticPseudonyms,
140
            $targetScopes,
141
            $serviceDisplayName,
142
            $serviceDescription,
143
        );
144
    }
145
146
147
    /**
148
     * Collect the value of the securityTokenServiceEndpoint-property
149
     *
150
     * @return \SimpleSAML\WSSecurity\XML\fed\SecurityTokenServiceEndpoint[]
151
     */
152
    public function getSecurityTokenServiceEndpoint(): array
153
    {
154
        return $this->securityTokenServiceEndpoint;
155
    }
156
157
158
    /**
159
     * Collect the value of the singleSignOutSubscriptionEndpoint-property
160
     *
161
     * @return \SimpleSAML\WSSecurity\XML\fed\SingleSignOutSubscriptionEndpoint[]
162
     */
163
    public function getSingleSignOutSubscriptionEndpoint(): array
164
    {
165
        return $this->singleSignOutSubscriptionEndpoint;
166
    }
167
168
169
    /**
170
     * Collect the value of the singleSignOutNotificationtionEndpoint-property
171
     *
172
     * @return \SimpleSAML\WSSecurity\XML\fed\SingleSignOutNotificationEndpoint[]
173
     */
174
    public function getSingleSignOutNotificationEndpoint(): array
175
    {
176
        return $this->singleSignOutNotificationEndpoint;
177
    }
178
179
180
    /**
181
     * Collect the value of the passiveRequestorEndpoint-property
182
     *
183
     * @return \SimpleSAML\WSSecurity\XML\fed\PassiveRequestorEndpoint[]
184
     */
185
    public function getPassiveRequestorEndpoint(): array
186
    {
187
        return $this->passiveRequestorEndpoint;
188
    }
189
190
191
    /**
192
     * Convert this element to XML.
193
     *
194
     * @param \DOMElement|null $parent The element we should append this element to.
195
     * @return \DOMElement
196
     */
197
    public function toUnsignedXML(?DOMElement $parent = null): DOMElement
198
    {
199
        $e = parent::toUnsignedXML($parent);
200
201
        foreach ($this->getSecurityTokenServiceEndpoint() as $stse) {
202
            $stse->toXML($e);
203
        }
204
205
        foreach ($this->getSingleSignOutSubscriptionEndpoint() as $ssose) {
206
            $ssose->toXML($e);
207
        }
208
209
        foreach ($this->getSingleSignOutNotificationEndpoint() as $ssone) {
210
            $ssone->toXML($e);
211
        }
212
213
        foreach ($this->getPassiveRequestorEndpoint() as $pre) {
214
            $pre->toXML($e);
215
        }
216
217
        return $e;
218
    }
219
}
220