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 |
||
22 | View Code Duplication | class ArrayWeGo extends AbstractExercise implements ExerciseInterface, FunctionRequirementsExerciseCheck, CliExercise |
|
23 | { |
||
24 | use TemporaryDirectoryTrait; |
||
25 | |||
26 | /** |
||
27 | * @var Filesystem |
||
28 | */ |
||
29 | private $filesystem; |
||
30 | |||
31 | /** |
||
32 | * @var Generator |
||
33 | */ |
||
34 | private $faker; |
||
35 | |||
36 | /** |
||
37 | * @param Filesystem $filesystem |
||
38 | * @param Generator $faker |
||
39 | */ |
||
40 | public function __construct(Filesystem $filesystem, Generator $faker) |
||
45 | |||
46 | /** |
||
47 | * @return string |
||
48 | */ |
||
49 | public function getName() |
||
53 | |||
54 | /** |
||
55 | * @return string |
||
56 | */ |
||
57 | public function getDescription() |
||
61 | |||
62 | /** |
||
63 | * @return array |
||
64 | */ |
||
65 | public function getArgs() |
||
83 | |||
84 | /** |
||
85 | * @return null |
||
86 | */ |
||
87 | public function tearDown() |
||
91 | |||
92 | /** |
||
93 | * @return string[] |
||
94 | */ |
||
95 | public function getRequiredFunctions() |
||
99 | |||
100 | /** |
||
101 | * @return string[] |
||
102 | */ |
||
103 | public function getBannedFunctions() |
||
107 | |||
108 | /** |
||
109 | * @return ExerciseType |
||
110 | */ |
||
111 | public function getType() |
||
115 | |||
116 | /** |
||
117 | * @param ExerciseDispatcher $dispatcher |
||
118 | */ |
||
119 | public function configure(ExerciseDispatcher $dispatcher) |
||
123 | } |
||
124 |