AbstractPseudonymServiceType::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 57
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 30
c 1
b 0
f 0
dl 0
loc 57
rs 9.44
cc 1
nc 1
nop 22

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 PseudonymServiceType
24
 *
25
 * @package simplesamlphp/ws-security
26
 */
27
abstract class AbstractPseudonymServiceType extends AbstractWebServiceDescriptorType
28
{
29
    /** @var string */
30
    public const XSI_TYPE_PREFIX = 'fed';
31
32
    /** @var string */
33
    public const XSI_TYPE_NAME = 'PseudonymServiceType';
34
35
    /** @var string */
36
    public const XSI_TYPE_NAMESPACE = C::NS_FED;
37
38
39
    /**
40
     * PseudonymServiceType 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[] $keyDescriptor 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[] $contact 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\PseudonymServiceEndpoint[] $pseudonymServiceEndpoint
70
     * @param \SimpleSAML\WSSecurity\XML\fed\SingleSignOutNotificationEndpoint[] $singleSignOutNotificationEndpoint
71
     */
72
    final public function __construct(
73
        QNameValue $type,
74
        SAMLAnyURIListValue $protocolSupportEnumeration,
75
        ?IDValue $ID = null,
76
        ?SAMLDateTimeValue $validUntil = null,
77
        ?DurationValue $cacheDuration = null,
78
        ?Extensions $extensions = null,
79
        ?SAMLAnyURIValue $errorURL = null,
80
        array $keyDescriptor = [],
81
        ?Organization $organization = null,
82
        array $contact = [],
83
        array $namespacedAttributes = [],
84
        ?LogicalServiceNamesOffered $logicalServiceNamesOffered = null,
85
        ?TokenTypesOffered $tokenTypesOffered = null,
86
        ?ClaimDialectsOffered $claimDialectsOffered = null,
87
        ?ClaimTypesOffered $claimTypesOffered = null,
88
        ?ClaimTypesRequested $claimTypesRequested = null,
89
        ?AutomaticPseudonyms $automaticPseudonyms = null,
90
        ?TargetScopes $targetScopes = null,
91
        ?SAMLStringValue $serviceDisplayName = null,
92
        ?SAMLStringValue $serviceDescription = null,
93
        protected array $pseudonymServiceEndpoint = [],
94
        protected array $singleSignOutNotificationEndpoint = [],
95
    ) {
96
        Assert::minCount($pseudonymServiceEndpoint, 1, MissingElementException::class);
97
        Assert::allIsInstanceOf(
98
            $pseudonymServiceEndpoint,
99
            PseudonymServiceEndpoint::class,
100
            SchemaViolationException::class,
101
        );
102
        Assert::allIsInstanceOf(
103
            $singleSignOutNotificationEndpoint,
104
            SingleSignOutNotificationEndpoint::class,
105
            SchemaViolationException::class,
106
        );
107
108
        parent::__construct(
109
            $type,
110
            $protocolSupportEnumeration,
111
            $ID,
112
            $validUntil,
113
            $cacheDuration,
114
            $extensions,
115
            $errorURL,
116
            $keyDescriptor,
117
            $organization,
118
            $contact,
119
            $namespacedAttributes,
120
            $logicalServiceNamesOffered,
121
            $tokenTypesOffered,
122
            $claimDialectsOffered,
123
            $claimTypesOffered,
124
            $claimTypesRequested,
125
            $automaticPseudonyms,
126
            $targetScopes,
127
            $serviceDisplayName,
128
            $serviceDescription,
129
        );
130
    }
131
132
133
    /**
134
     * Collect the value of the pseudonymServicEndpoint-property
135
     *
136
     * @return \SimpleSAML\WSSecurity\XML\fed\PseudonymServiceEndpoint[]
137
     */
138
    public function getPseudonymServiceEndpoint(): array
139
    {
140
        return $this->pseudonymServiceEndpoint;
141
    }
142
143
144
    /**
145
     * Collect the value of the singleSignOutNotificationtionEndpoint-property
146
     *
147
     * @return \SimpleSAML\WSSecurity\XML\fed\SingleSignOutNotificationEndpoint[]
148
     */
149
    public function getSingleSignOutNotificationEndpoint(): array
150
    {
151
        return $this->singleSignOutNotificationEndpoint;
152
    }
153
154
155
    /**
156
     * Convert this element to XML.
157
     *
158
     * @param \DOMElement|null $parent The element we should append this element to.
159
     * @return \DOMElement
160
     */
161
    public function toUnsignedXML(?DOMElement $parent = null): DOMElement
162
    {
163
        $e = parent::toXML($parent);
164
165
        foreach ($this->getPseudonymServiceEndpoint() as $pse) {
166
            $pse->toXML($e);
167
        }
168
169
        foreach ($this->getSingleSignOutNotificationEndpoint() as $ssone) {
170
            $ssone->toXML($e);
171
        }
172
173
        return $e;
174
    }
175
}
176