Conditions | 10 |
Paths | 5 |
Total Lines | 67 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
130 | protected function addUrls(ProviderInterface $provider) |
||
131 | { |
||
132 | |||
133 | $variables = []; |
||
134 | $variables['assertionConsumerServices'] = null; |
||
135 | $variables['singleLogoutServices'] = null; |
||
136 | $variables['singleSignOnServices'] = null; |
||
137 | |||
138 | if (! $provider->getMetadataModel()) { |
||
139 | return $variables; |
||
140 | } |
||
141 | |||
142 | /** @var AbstractPlugin $plugin */ |
||
143 | $plugin = $this->getPlugin(); |
||
144 | |||
145 | /** |
||
146 | * Metadata/EntityDescriptor Model |
||
147 | */ |
||
148 | $entityDescriptor = $provider->getMetadataModel(); |
||
149 | |||
150 | /** |
||
151 | * Add SP URLs |
||
152 | */ |
||
153 | if ($provider->getType() === AbstractSettings::SP) { |
||
154 | foreach ($entityDescriptor->getRoleDescriptor() as $roleDescriptor) { |
||
155 | if (! ($roleDescriptor instanceof SPSSODescriptor)) { |
||
156 | continue; |
||
157 | } |
||
158 | |||
159 | if ($endpoint = $this->getFirstEndpoint($roleDescriptor->getSingleLogoutService())) { |
||
160 | $sloBinding = $endpoint->getBinding(); |
||
161 | $sloResponseLocation = $endpoint->getResponseLocation(); |
||
162 | $variables['singleLogoutServices'][$sloBinding] = $sloResponseLocation; |
||
163 | } |
||
164 | |||
165 | /** @var IndexedEndpointType $firstACS */ |
||
166 | $firstACS = $this->getFirstEndpoint($roleDescriptor->getAssertionConsumerService()); |
||
167 | $acsBinding = $firstACS->getBinding(); |
||
168 | $acsLocation = $firstACS->getLocation(); |
||
169 | $variables['assertionConsumerServices'][$acsBinding] = $acsLocation; |
||
170 | } |
||
171 | } |
||
172 | |||
173 | /** |
||
174 | * Add IDP URLs |
||
175 | */ |
||
176 | if ($provider->getType() === AbstractSettings::IDP) { |
||
177 | foreach ($entityDescriptor->getRoleDescriptor() as $roleDescriptor) { |
||
178 | if (! ($roleDescriptor instanceof IDPSSODescriptor)) { |
||
179 | continue; |
||
180 | } |
||
181 | |||
182 | if ($endpoint = $this->getFirstEndpoint($roleDescriptor->getSingleLogoutService())) { |
||
183 | $sloBinding = $endpoint->getBinding(); |
||
184 | $sloResponseLocation = $endpoint->getResponseLocation(); |
||
185 | $variables['singleLogoutServices'][$sloBinding] = $sloResponseLocation; |
||
186 | } |
||
187 | |||
188 | $sso = $this->getFirstEndpoint($roleDescriptor->getSingleSignOnService()); |
||
189 | $ssoBinding = $sso->getBinding(); |
||
190 | $ssoLocation = $sso->getLocation(); |
||
191 | $variables['singleSignOnServices'][$ssoBinding] = $ssoLocation; |
||
192 | } |
||
193 | } |
||
194 | |||
195 | return $variables; |
||
196 | } |
||
197 | |||
221 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.