Conditions | 1 |
Paths | 1 |
Total Lines | 209 |
Code Lines | 97 |
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 |
||
395 | public function outputData() |
||
396 | { |
||
397 | return [ |
||
398 | [ // verbose with single valid run |
||
399 | OutputInterface::VERBOSITY_VERBOSE, |
||
400 | false, |
||
401 | false, |
||
402 | [true], |
||
403 | [ |
||
404 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %'], |
||
405 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%'], |
||
406 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%'], |
||
407 | ], |
||
408 | ], |
||
409 | [ // normal verbosity only writes a single line |
||
410 | OutputInterface::VERBOSITY_NORMAL, |
||
411 | false, |
||
412 | false, |
||
413 | [true], |
||
414 | [ |
||
415 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%'], |
||
416 | ], |
||
417 | ], |
||
418 | [ |
||
419 | OutputInterface::VERBOSITY_NORMAL, |
||
420 | false, |
||
421 | false, |
||
422 | [true, true], |
||
423 | [ |
||
424 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%'], |
||
425 | ['%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%'], |
||
426 | ], |
||
427 | ], |
||
428 | [ // multiple runs with verbosity will update each item one at a time |
||
429 | OutputInterface::VERBOSITY_VERBOSE, |
||
430 | false, |
||
431 | false, |
||
432 | [true, true], |
||
433 | [ |
||
434 | [ |
||
435 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
436 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
437 | ], |
||
438 | [ |
||
439 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
440 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
441 | ], |
||
442 | [ |
||
443 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
444 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
445 | ], |
||
446 | [ |
||
447 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
448 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
449 | ], |
||
450 | [ |
||
451 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
452 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
453 | ], |
||
454 | ], |
||
455 | ], |
||
456 | [ // errors will display an error |
||
457 | OutputInterface::VERBOSITY_VERBOSE, |
||
458 | false, |
||
459 | false, |
||
460 | [false], |
||
461 | [ |
||
462 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %'], |
||
463 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%'], |
||
464 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <error>x</error>%'], |
||
465 | [ |
||
466 | <<<DOC |
||
467 | %The command "test" failed. |
||
468 | |||
469 | Exit Code: 1\(failed\) |
||
470 | |||
471 | Working directory: /tmp |
||
472 | |||
473 | Output: |
||
474 | ================ |
||
475 | some text |
||
476 | |||
477 | Error Output: |
||
478 | ================ |
||
479 | some error text% |
||
480 | DOC |
||
481 | , |
||
482 | ], |
||
483 | ], |
||
484 | ], |
||
485 | [ // errors will display an error |
||
486 | OutputInterface::VERBOSITY_NORMAL, |
||
487 | false, |
||
488 | false, |
||
489 | [false], |
||
490 | [ |
||
491 | ['%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <error>x</error>%'], |
||
492 | [ |
||
493 | <<<DOC |
||
494 | %The command "test" failed. |
||
495 | |||
496 | Exit Code: 1\(failed\) |
||
497 | |||
498 | Working directory: /tmp |
||
499 | |||
500 | Output: |
||
501 | ================ |
||
502 | some text |
||
503 | |||
504 | Error Output: |
||
505 | ================ |
||
506 | some error text% |
||
507 | DOC |
||
508 | , |
||
509 | ], |
||
510 | ], |
||
511 | ], |
||
512 | [ // multiple runs with verbosity will update each item one at a time |
||
513 | OutputInterface::VERBOSITY_VERBOSE, |
||
514 | false, |
||
515 | false, |
||
516 | [true, false], |
||
517 | [ |
||
518 | [ |
||
519 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
520 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
521 | ], |
||
522 | [ |
||
523 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
524 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
525 | ], |
||
526 | [ |
||
527 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
528 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
529 | ], |
||
530 | [ |
||
531 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
532 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
533 | ], |
||
534 | [ |
||
535 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
536 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) <error>x</error>%', |
||
537 | ], |
||
538 | [ |
||
539 | <<<DOC |
||
540 | %The command "test" failed. |
||
541 | |||
542 | Exit Code: 1\(failed\) |
||
543 | |||
544 | Working directory: /tmp |
||
545 | |||
546 | Output: |
||
547 | ================ |
||
548 | some text |
||
549 | |||
550 | Error Output: |
||
551 | ================ |
||
552 | some error text% |
||
553 | DOC |
||
554 | , |
||
555 | ], |
||
556 | ], |
||
557 | ], |
||
558 | [ // include output |
||
559 | OutputInterface::VERBOSITY_VERBOSE, |
||
560 | true, |
||
561 | false, |
||
562 | [true], |
||
563 | [ |
||
564 | ['%(*UTF8)<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %'], |
||
565 | ['%(*UTF8)<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏] some text%'], |
||
566 | ['%(*UTF8)<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info> some text%'], |
||
567 | ], |
||
568 | ], |
||
569 | [ // include a summary |
||
570 | OutputInterface::VERBOSITY_VERBOSE, |
||
571 | false, |
||
572 | true, |
||
573 | [true, true], |
||
574 | [ |
||
575 | [ |
||
576 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
577 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
578 | '%^waiting...$%', |
||
579 | ], |
||
580 | [ |
||
581 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
582 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) %', |
||
583 | '%<comment>Total</comment>: 2, <comment>Running</comment>: 2, <comment>Waiting</comment>: 0%', |
||
584 | ], |
||
585 | [ |
||
586 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
587 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
588 | '%<comment>Total</comment>: 2, <comment>Running</comment>: 2, <comment>Waiting</comment>: 0%', |
||
589 | ], |
||
590 | [ |
||
591 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
592 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) [⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]%', |
||
593 | '%<comment>Total</comment>: 2, <comment>Running</comment>: 2, <comment>Waiting</comment>: 0%', |
||
594 | ], |
||
595 | [ |
||
596 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
597 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
598 | '%<comment>Total</comment>: 2, <comment>Running</comment>: 1, <comment>Waiting</comment>: 0%', |
||
599 | ], |
||
600 | [ |
||
601 | '%<info>key</info>: value <info>run</info>: 0 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
602 | '%<info>key</info>: value <info>run</info>: 1 \(<comment>[ 0-9\.s]+</comment>\) <info>✓</info>%', |
||
603 | '%^$%', |
||
604 | ], |
||
610 |