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) |
|
| 31 | |||
| 32 | /** |
||
| 33 | * @param InputInterface $input |
||
| 34 | * @return Alias |
||
| 35 | */ |
||
| 36 | 4 | View Code Duplication | private function buildAlias(InputInterface $input) |
| 46 | |||
| 47 | /** |
||
| 48 | * @param InputInterface $input |
||
| 49 | * @param OutputInterface $output |
||
| 50 | * @param Alias $alias |
||
| 51 | * @return bool |
||
| 52 | */ |
||
| 53 | 4 | private function canBeSaved(InputInterface $input, OutputInterface $output, Alias $alias) |
|
| 58 | |||
| 59 | /** |
||
| 60 | * @param InputInterface $input |
||
| 61 | * @param OutputInterface $output |
||
| 62 | * @param Alias $alias |
||
| 63 | * @return mixed |
||
| 64 | */ |
||
| 65 | 2 | private function confirmOverride(InputInterface $input, OutputInterface $output, Alias $alias) |
|
| 73 | |||
| 74 | /** |
||
| 75 | * @param Alias $newAlias |
||
| 76 | * @return Alias |
||
| 77 | */ |
||
| 78 | 2 | private function getInitialAlias(Alias $newAlias) |
|
| 82 | |||
| 83 | /** |
||
| 84 | * @param Alias $newAlias |
||
| 85 | * @param Alias $oldAlias |
||
| 86 | * @return ConfirmationQuestion |
||
| 87 | */ |
||
| 88 | 2 | private function buildQuestion(Alias $newAlias, Alias $oldAlias) |
|
| 98 | } |
||
| 99 |