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 |
||
14 | View Code Duplication | class HomepageQuestion extends Question |
|
15 | { |
||
16 | /** |
||
17 | * @param InputInterface $input |
||
18 | * @param OutputInterface $output |
||
19 | * @return int |
||
20 | */ |
||
21 | 5 | public function execute(InputInterface $input, OutputInterface $output) |
|
30 | |||
31 | /** |
||
32 | * @return SimpleQuestion |
||
33 | */ |
||
34 | 5 | private function buildQuestion() |
|
41 | |||
42 | /** |
||
43 | * @return callable |
||
44 | */ |
||
45 | private function buildValidator() |
||
54 | |||
55 | } |
||
56 |