| Conditions | 11 |
| Paths | 356 |
| Total Lines | 54 |
| Code Lines | 33 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 89 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 90 | { |
||
| 91 | $finder = new PHPFinder(); |
||
| 92 | $finder |
||
| 93 | ->in($input->getArgument('directory')) |
||
| 94 | ->exclude(array_merge(['vendor'], $input->getOption('exclude'))); |
||
| 95 | |||
| 96 | foreach ($input->getOption('exclude-path') as $notPath) { |
||
| 97 | $finder->notPath($notPath); |
||
| 98 | } |
||
| 99 | |||
| 100 | foreach ($input->getOption('exclude-file') as $notName) { |
||
| 101 | $finder->notName($notName); |
||
| 102 | } |
||
| 103 | |||
| 104 | if (0 === $finder->count()) { |
||
| 105 | $output->writeln('No files found to scan'); |
||
| 106 | exit(1); |
||
| 107 | } |
||
| 108 | |||
| 109 | $progressBar = null; |
||
| 110 | if ($input->getOption('progress')) { |
||
| 111 | $progressBar = new ProgressBar($output, $finder->count()); |
||
| 112 | $progressBar->start(); |
||
| 113 | } |
||
| 114 | |||
| 115 | $detector = new Detector($this->createOption($input)); |
||
| 116 | |||
| 117 | $printer = new Printer(); |
||
| 118 | foreach ($finder as $file) { |
||
| 119 | try { |
||
| 120 | $fileReport = $detector->detect($file); |
||
| 121 | if ($fileReport->hasMagicNumbers()) { |
||
| 122 | $printer->addFileReport($fileReport); |
||
| 123 | } |
||
| 124 | } catch (\Exception $e) { |
||
| 125 | $output->writeln($e->getMessage()); |
||
| 126 | } |
||
| 127 | |||
| 128 | if ($input->getOption('progress')) { |
||
| 129 | $progressBar->advance(); |
||
| 130 | } |
||
| 131 | } |
||
| 132 | |||
| 133 | if ($input->getOption('progress')) { |
||
| 134 | $progressBar->finish(); |
||
| 135 | } |
||
| 136 | |||
| 137 | if ($output->getVerbosity() !== OutputInterface::VERBOSITY_QUIET) { |
||
| 138 | $output->writeln(''); |
||
| 139 | $printer->printData($output); |
||
| 140 | $output->writeln('<info>' . \PHP_Timer::resourceUsage() . '</info>'); |
||
| 141 | } |
||
| 142 | } |
||
| 143 | |||
| 193 |