Conditions | 1 |
Paths | 1 |
Total Lines | 182 |
Code Lines | 91 |
Lines | 0 |
Ratio | 0 % |
Changes | 32 | ||
Bugs | 0 | Features | 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 declare(strict_types=1); |
||
305 | public function getDecodeInvalidTests() |
||
306 | { |
||
307 | return [ |
||
308 | [ |
||
309 | null, |
||
310 | new TypeError(Bencode::class . '::decode(): Argument #1 ($bencoded) must be of type string, null given') |
||
311 | ], |
||
312 | [ |
||
313 | '', |
||
314 | new DecodingException('Premature end of data', 0) |
||
315 | ], |
||
316 | [ |
||
317 | 'lxe', |
||
318 | new DecodingException('Illegal character', 1) |
||
319 | ], |
||
320 | [ |
||
321 | 'l', |
||
322 | new DecodingException('Premature end of data', 0) |
||
323 | ], |
||
324 | [ |
||
325 | 'lle', |
||
326 | new DecodingException('Premature end of data', 2) |
||
327 | ], |
||
328 | [ |
||
329 | 'lee', |
||
330 | new ComplianceError('Superfluous content', 2) |
||
331 | ], |
||
332 | [ |
||
333 | 'le0', |
||
334 | new ComplianceError('Superfluous content', 2) |
||
335 | ], |
||
336 | [ |
||
337 | 'ddee', |
||
338 | new DecodingException('Illegal character', 1) |
||
339 | ], |
||
340 | [ |
||
341 | 'd1:xe', |
||
342 | new DecodingException('Illegal character', 4) |
||
343 | ], |
||
344 | [ |
||
345 | 'd1:xl', |
||
346 | new DecodingException('Premature end of data', 4) |
||
347 | ], |
||
348 | [ |
||
349 | 'd1:xx', |
||
350 | new DecodingException('Illegal character', 4) |
||
351 | ], |
||
352 | [ |
||
353 | 'ie', |
||
354 | new DecodingException('Illegal character', 1) |
||
355 | ], |
||
356 | [ |
||
357 | 'i1x', |
||
358 | new DecodingException('Illegal character', 2) |
||
359 | ], |
||
360 | [ |
||
361 | 'lxe', |
||
362 | new DecodingException('Illegal character', 1) |
||
363 | ], |
||
364 | [ |
||
365 | '3:abcd', |
||
366 | new ComplianceError('Superfluous content', 5) |
||
367 | ], |
||
368 | [ |
||
369 | 'li', |
||
370 | new DecodingException('Premature end of data', 1) |
||
371 | ], |
||
372 | [ |
||
373 | 'l3', |
||
374 | new DecodingException('Premature end of data', 1) |
||
375 | ], |
||
376 | [ |
||
377 | 'i-1-e', |
||
378 | new DecodingException('Illegal character', 3) |
||
379 | ], |
||
380 | [ |
||
381 | 'i', |
||
382 | new DecodingException('Premature end of data', 0) |
||
383 | ], |
||
384 | [ |
||
385 | 'i-', |
||
386 | new DecodingException('Premature end of data', 1) |
||
387 | ], |
||
388 | [ |
||
389 | 'd1:xi-', |
||
390 | new DecodingException('Premature end of data', 5) |
||
391 | ], |
||
392 | [ |
||
393 | 'i1', |
||
394 | new DecodingException('Premature end of data', 1) |
||
395 | ], |
||
396 | [ |
||
397 | 'i-1', |
||
398 | new DecodingException('Premature end of data', 2) |
||
399 | ], |
||
400 | [ |
||
401 | 'lli123', |
||
402 | new DecodingException('Premature end of data', 5) |
||
403 | ], |
||
404 | [ |
||
405 | '3 abc', |
||
406 | new DecodingException('Illegal character', 1) |
||
407 | ], |
||
408 | [ |
||
409 | '3a3:abc', |
||
410 | new DecodingException('Illegal character', 1) |
||
411 | ], |
||
412 | [ |
||
413 | '3a', |
||
414 | new DecodingException('Illegal character', 1) |
||
415 | ], |
||
416 | [ |
||
417 | ':a', |
||
418 | new DecodingException('Illegal character', 0) |
||
419 | ], |
||
420 | [ |
||
421 | '3:abc3:abc', |
||
422 | new ComplianceError('Superfluous content', 5) |
||
423 | ], |
||
424 | [ |
||
425 | '3:abci', |
||
426 | new ComplianceError('Superfluous content', 5) |
||
427 | ], |
||
428 | [ |
||
429 | '3:', |
||
430 | new DecodingException('Premature end of data', 1) |
||
431 | ], |
||
432 | [ |
||
433 | '3:a', |
||
434 | new DecodingException('Premature end of data', 2) |
||
435 | ], |
||
436 | [ |
||
437 | '2:a', |
||
438 | new DecodingException('Premature end of data', 2) |
||
439 | ], |
||
440 | [ |
||
441 | 'l11:ae', |
||
442 | new DecodingException('Premature end of data', 5) |
||
443 | ], |
||
444 | [ |
||
445 | 'i0123e', |
||
446 | new ComplianceError('Illegal character', 2) |
||
447 | ], |
||
448 | [ |
||
449 | 'i00e', |
||
450 | new ComplianceError('Illegal character', 2) |
||
451 | ], |
||
452 | [ |
||
453 | 'i-0e', |
||
454 | new ComplianceError('Illegal character', 2) |
||
455 | ], |
||
456 | [ |
||
457 | '01:a', |
||
458 | new ComplianceError('Illegal character', 1) |
||
459 | ], |
||
460 | [ |
||
461 | '1', |
||
462 | new DecodingException('Premature end of data', 0) |
||
463 | ], |
||
464 | [ |
||
465 | 'e', |
||
466 | new DecodingException('Illegal character', 0) |
||
467 | ], |
||
468 | [ |
||
469 | '-1', |
||
470 | new DecodingException('Illegal character', 0) |
||
471 | ], |
||
472 | [ |
||
473 | 'd3:fooi0e3:foo3:abce', |
||
474 | new ComplianceError("Duplicate dictionary entry 'foo'", 9) |
||
475 | ], |
||
476 | [ |
||
477 | 'd4:abcdi0e4:abcdli0eee', |
||
478 | new ComplianceError("Duplicate dictionary entry 'abcd'", 10) |
||
479 | ], |
||
480 | [ |
||
481 | 'd3:fooi0e3:bar3:abce', |
||
482 | new ComplianceError("Out of order dictionary entry 'bar'", 9) |
||
483 | ], |
||
484 | [ |
||
485 | 'd1:5i0e2:11i0ee', |
||
486 | new ComplianceError("Out of order dictionary entry '11'", 7) |
||
487 | ], |
||
509 | } |