Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 17 | class Listing extends Task |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @param InputInterface $input |
||
| 21 | * @param OutputInterface $output |
||
| 22 | * @return int |
||
| 23 | */ |
||
| 24 | 4 | public function execute(InputInterface $input, OutputInterface $output) |
|
| 31 | |||
| 32 | /** |
||
| 33 | * @param $moduleName |
||
| 34 | * @param OutputInterface $output |
||
| 35 | * @return int |
||
| 36 | */ |
||
| 37 | 2 | View Code Duplication | private function listModule($moduleName, OutputInterface $output) |
| 51 | |||
| 52 | /** |
||
| 53 | * @param OutputInterface $output |
||
| 54 | * @return int |
||
| 55 | */ |
||
| 56 | 2 | private function listModules(OutputInterface $output) |
|
| 62 | |||
| 63 | /** |
||
| 64 | * @param Modules $modules |
||
| 65 | * @return string |
||
| 66 | */ |
||
| 67 | 2 | private function mapModules(Modules $modules) |
|
| 75 | |||
| 76 | /** |
||
| 77 | * @param Module $module |
||
| 78 | * @return string |
||
| 79 | */ |
||
| 80 | 3 | View Code Duplication | private function mapModule(Module $module) |
| 90 | } |
||
| 91 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.