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 Listing extends Task |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @param InputInterface $input |
||
| 20 | * @param OutputInterface $output |
||
| 21 | * @return int |
||
| 22 | */ |
||
| 23 | 8 | public function execute(InputInterface $input, OutputInterface $output) |
|
| 30 | |||
| 31 | /** |
||
| 32 | * @param InputInterface $input |
||
| 33 | * @param OutputInterface $output |
||
| 34 | * @return int |
||
| 35 | */ |
||
| 36 | 6 | private function listAliases(InputInterface $input, OutputInterface $output) |
|
| 47 | |||
| 48 | /** |
||
| 49 | * @param $aliasName |
||
| 50 | * @param OutputInterface $output |
||
| 51 | * @return int |
||
| 52 | */ |
||
| 53 | 2 | View Code Duplication | private function listAlias($aliasName, OutputInterface $output) |
| 67 | |||
| 68 | /** |
||
| 69 | * @param Alias[] $aliases |
||
| 70 | * @return string |
||
| 71 | */ |
||
| 72 | 6 | private function mapAliases(array $aliases) |
|
| 80 | |||
| 81 | /** |
||
| 82 | * @param Alias $alias |
||
| 83 | * @return string |
||
| 84 | */ |
||
| 85 | 7 | View Code Duplication | private function mapAlias(Alias $alias) |
| 95 | } |
||
| 96 |