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 |
||
| 16 | class Saving extends Task |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @param InputInterface $input |
||
| 20 | * @param OutputInterface $output |
||
| 21 | * @return bool |
||
| 22 | */ |
||
| 23 | 4 | public function execute(InputInterface $input, OutputInterface $output) |
|
| 34 | |||
| 35 | /** |
||
| 36 | * @param InputInterface $input |
||
| 37 | * @return Module |
||
| 38 | */ |
||
| 39 | 4 | View Code Duplication | private function buildModuleFromInput(InputInterface $input) |
| 50 | |||
| 51 | /** |
||
| 52 | * @param InputInterface $input |
||
| 53 | * @param OutputInterface $output |
||
| 54 | * @param Module $newModule |
||
| 55 | * @return bool |
||
| 56 | */ |
||
| 57 | 4 | private function canBeSaved(InputInterface $input, OutputInterface $output, Module $newModule) |
|
| 62 | |||
| 63 | /** |
||
| 64 | * @param InputInterface $input |
||
| 65 | * @param OutputInterface $output |
||
| 66 | * @param Module $oldModule |
||
| 67 | * @param Module $newModule |
||
| 68 | * @return mixed |
||
| 69 | */ |
||
| 70 | 2 | private function confirmOverride(InputInterface $input, OutputInterface $output, Module $oldModule, Module $newModule) |
|
| 78 | |||
| 79 | /** |
||
| 80 | * @param Module $oldModule |
||
| 81 | * @param Module $newModule |
||
| 82 | * @return ConfirmationQuestion |
||
| 83 | * @internal param Module $module |
||
| 84 | */ |
||
| 85 | 2 | private function buildQuestion(Module $oldModule, Module $newModule) |
|
| 95 | |||
| 96 | /** |
||
| 97 | * @param Module $newModule |
||
| 98 | * @return Module |
||
| 99 | */ |
||
| 100 | 4 | private function getInitialModule(Module $newModule) |
|
| 104 | } |
||
| 105 |
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.