| Conditions | 14 |
| Paths | 256 |
| Total Lines | 59 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 |
||
| 61 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 62 | { |
||
| 63 | $failureCount = 0; |
||
| 64 | |||
| 65 | $groups = $input->getOption('group') ?: array(null); |
||
| 66 | $allGroups = $input->getOption('all'); |
||
| 67 | $checkName = $input->getArgument('checkName'); |
||
| 68 | $nagios = $input->getOption('nagios'); |
||
| 69 | $additionalReporters = $input->getOption('reporter'); |
||
| 70 | |||
| 71 | if ($nagios) { |
||
| 72 | $reporter = $this->rawReporter; |
||
| 73 | } else { |
||
| 74 | $reporter = $this->reporter; |
||
| 75 | } |
||
| 76 | |||
| 77 | if ($allGroups) { |
||
| 78 | $groups = $this->runnerManager->getGroups(); |
||
| 79 | } |
||
| 80 | |||
| 81 | foreach ($groups as $group) { |
||
| 82 | if (count($groups) > 1 || $allGroups) { |
||
| 83 | $output->writeln(sprintf('<fg=yellow;options=bold>%s</>', $group)); |
||
| 84 | } |
||
| 85 | |||
| 86 | $runner = $this->runnerManager->getRunner($group); |
||
| 87 | |||
| 88 | if (null === $runner) { |
||
| 89 | $output->writeln('<error>No such group.</error>'); |
||
| 90 | |||
| 91 | return 1; |
||
| 92 | } |
||
| 93 | |||
| 94 | $runner->addReporter($reporter); |
||
| 95 | $runner->useAdditionalReporters($additionalReporters); |
||
| 96 | |||
| 97 | if (0 === count($runner->getChecks())) { |
||
| 98 | $output->writeln('<error>No checks configured.</error>'); |
||
| 99 | } |
||
| 100 | |||
| 101 | $results = $runner->run($checkName); |
||
| 102 | |||
| 103 | if ($nagios) { |
||
| 104 | if ($results->getUnknownCount()) { |
||
| 105 | return 3; |
||
| 106 | } |
||
| 107 | if ($results->getFailureCount()) { |
||
| 108 | return 2; |
||
| 109 | } |
||
| 110 | if ($results->getWarningCount()) { |
||
| 111 | return 1; |
||
| 112 | } |
||
| 113 | } |
||
| 114 | |||
| 115 | $failureCount += $results->getFailureCount(); |
||
| 116 | } |
||
| 117 | |||
| 118 | return $failureCount > 0 ? 1 : 0; |
||
| 119 | } |
||
| 120 | } |
||
| 121 |