We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 1 |
Paths | 1 |
Total Lines | 108 |
Code Lines | 50 |
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 |
||
250 | public function parentExceptionMappingDataProvider() |
||
251 | { |
||
252 | return [ |
||
253 | 'without $mapExceptionsToParent and only the exact class, maps to exact class' => [ |
||
254 | [ |
||
255 | ChildOfInvalidArgumentException::class => UserError::class, |
||
256 | ], |
||
257 | false, |
||
258 | [ |
||
259 | 'errors' => [ |
||
260 | [ |
||
261 | 'message' => 'Error with invalid argument exception', |
||
262 | 'category' => 'user', |
||
263 | ], |
||
264 | ], |
||
265 | ], |
||
266 | ], |
||
267 | 'without $mapExceptionsToParent and only the parent class, does not map to parent' => [ |
||
268 | [ |
||
269 | \InvalidArgumentException::class => UserWarning::class, |
||
270 | ], |
||
271 | false, |
||
272 | ChildOfInvalidArgumentException::class, |
||
273 | ], |
||
274 | 'with $mapExceptionsToParent and no classes' => [ |
||
275 | [], |
||
276 | true, |
||
277 | ChildOfInvalidArgumentException::class, |
||
278 | ], |
||
279 | 'with $mapExceptionsToParent and only the exact class' => [ |
||
280 | [ |
||
281 | ChildOfInvalidArgumentException::class => UserError::class, |
||
282 | ], |
||
283 | true, |
||
284 | [ |
||
285 | 'errors' => [ |
||
286 | [ |
||
287 | 'message' => 'Error with invalid argument exception', |
||
288 | 'category' => 'user', |
||
289 | ], |
||
290 | ], |
||
291 | ], |
||
292 | ], |
||
293 | 'with $mapExceptionsToParent and only the parent class' => [ |
||
294 | [ |
||
295 | \InvalidArgumentException::class => UserWarning::class, |
||
296 | ], |
||
297 | true, |
||
298 | [ |
||
299 | 'extensions' => [ |
||
300 | 'warnings' => [ |
||
301 | [ |
||
302 | 'message' => 'Error with invalid argument exception', |
||
303 | 'category' => 'user', |
||
304 | ], |
||
305 | ], |
||
306 | ], |
||
307 | ], |
||
308 | ], |
||
309 | 'with $mapExceptionsToParent and the exact class first matches exact class' => [ |
||
310 | [ |
||
311 | ChildOfInvalidArgumentException::class => UserError::class, |
||
312 | \InvalidArgumentException::class => UserWarning::class, |
||
313 | ], |
||
314 | true, |
||
315 | [ |
||
316 | 'errors' => [ |
||
317 | [ |
||
318 | 'message' => 'Error with invalid argument exception', |
||
319 | 'category' => 'user', |
||
320 | ], |
||
321 | ], |
||
322 | ], |
||
323 | ], |
||
324 | 'with $mapExceptionsToParent and the exact class first but parent maps to error' => [ |
||
325 | [ |
||
326 | ChildOfInvalidArgumentException::class => UserWarning::class, |
||
327 | \InvalidArgumentException::class => UserError::class, |
||
328 | ], |
||
329 | true, |
||
330 | [ |
||
331 | 'extensions' => [ |
||
332 | 'warnings' => [ |
||
333 | [ |
||
334 | 'message' => 'Error with invalid argument exception', |
||
335 | 'category' => 'user', |
||
336 | ], |
||
337 | ], |
||
338 | ], |
||
339 | ], |
||
340 | ], |
||
341 | 'with $mapExceptionsToParent and the parent class first still matches exact class' => [ |
||
342 | [ |
||
343 | \InvalidArgumentException::class => UserWarning::class, |
||
344 | ChildOfInvalidArgumentException::class => UserError::class, |
||
345 | ], |
||
346 | true, |
||
347 | [ |
||
348 | 'errors' => [ |
||
349 | [ |
||
350 | 'message' => 'Error with invalid argument exception', |
||
351 | 'category' => 'user', |
||
352 | ], |
||
353 | ], |
||
354 | ], |
||
355 | ], |
||
356 | ]; |
||
357 | } |
||
358 | } |
||
359 |