Conditions | 8 |
Paths | 5 |
Total Lines | 54 |
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 |
||
133 | protected function addUrls(ProviderInterface $provider) |
||
134 | { |
||
135 | |||
136 | $variables = []; |
||
137 | $variables['assertionConsumerServices'] = null; |
||
138 | $variables['singleLogoutServices'] = null; |
||
139 | $variables['singleSignOnServices'] = null; |
||
140 | |||
141 | if (! $provider->getMetadataModel()) { |
||
142 | return $variables; |
||
143 | } |
||
144 | |||
145 | /** @var AbstractPlugin $plugin */ |
||
146 | $plugin = $this->getSamlPlugin(); |
||
147 | |||
148 | /** |
||
149 | * Add SP URLs |
||
150 | */ |
||
151 | if ($provider->getType() === $plugin::SP) { |
||
152 | foreach ($provider-> |
||
153 | getMetadataModel()-> |
||
154 | getFirstSpSsoDescriptor()-> |
||
155 | getAllSingleLogoutServices() as $singleLogoutService) { |
||
156 | $variables['singleLogoutServices'][$singleLogoutService->getBinding()] = |
||
157 | $singleLogoutService->getResponseLocation(); |
||
158 | } |
||
159 | foreach ($provider->getMetadataModel()-> |
||
160 | getFirstSpSsoDescriptor()-> |
||
161 | getAllAssertionConsumerServices() as $assertionConsumerService) { |
||
162 | $variables['assertionConsumerServices'][$assertionConsumerService->getBinding()] = |
||
163 | $assertionConsumerService->getLocation(); |
||
164 | } |
||
165 | } |
||
166 | |||
167 | /** |
||
168 | * Add IDP URLs |
||
169 | */ |
||
170 | if ($provider->getType() === $plugin::IDP) { |
||
171 | foreach ($provider->getMetadataModel()-> |
||
172 | getFirstIdpSsoDescriptor()-> |
||
173 | getAllSingleLogoutServices() as $singleLogoutService) { |
||
174 | $variables['singleLogoutServices'][$singleLogoutService->getBinding()] = |
||
175 | $singleLogoutService->getLocation(); |
||
176 | } |
||
177 | |||
178 | foreach ($provider->getMetadataModel()-> |
||
179 | getFirstIdpSsoDescriptor()-> |
||
180 | getAllSingleSignOnServices() as $signOnService) { |
||
181 | $variables['singleSignOnServices'][$signOnService->getBinding()] = $signOnService->getLocation(); |
||
182 | } |
||
183 | } |
||
184 | |||
185 | return $variables; |
||
186 | } |
||
187 | |||
200 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: