| Conditions | 13 |
| Paths | 25 |
| Total Lines | 37 |
| Code Lines | 24 |
| 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 |
||
| 81 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 82 | { |
||
| 83 | if ($input->getArgument('directory') || $input->getArgument('namespace')) { |
||
| 84 | if (!$input->getArgument('directory') || !$input->getArgument('namespace')) { |
||
| 85 | throw new NotFoundException('Missing either the directory or namespace argument. If one is used, then both are required'); |
||
| 86 | } |
||
| 87 | } |
||
| 88 | |||
| 89 | $paths = []; |
||
| 90 | if ($input->getArgument('directory') || $input->getArgument('namespace')) { |
||
| 91 | $paths = $this->traverseDirectory(realpath($input->getArgument('directory')), $input->getArgument('namespace')); |
||
| 92 | } else { |
||
| 93 | foreach (self::$dirs as $dir => $namespace) { |
||
| 94 | $result = $this->traverseDirectory($dir, $namespace); |
||
| 95 | $paths = array_merge($paths, $result); |
||
| 96 | } |
||
| 97 | } |
||
| 98 | |||
| 99 | sort($paths); |
||
| 100 | $filter = $input->getArgument('filter'); |
||
| 101 | if (count($paths) > 0 ) { |
||
| 102 | $output->writeln('Classes found: '); |
||
| 103 | $escape = $input->getOption('escape'); |
||
| 104 | |||
| 105 | foreach ($paths as $path) { |
||
| 106 | if ($escape) { |
||
| 107 | $path = str_replace('\\', '\\\\', $path); |
||
| 108 | } |
||
| 109 | if ($filter && stripos($path, $filter) !== false) { |
||
| 110 | $output->writeln("\t" . $path); |
||
| 111 | } |
||
| 112 | } |
||
| 113 | } else { |
||
| 114 | $output->writeln('No classes found. If you were expecting to find some you might need to escape your namespace separators'); |
||
| 115 | $output->writeln('e.g. Namespace\Class should be written as Namespace\\\\Class'); |
||
| 116 | } |
||
| 117 | } |
||
| 118 | |||
| 157 | } |