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 |
||
| 17 | View Code Duplication | class ExceptionalCoding extends AbstractExercise implements |
|
| 18 | ExerciseInterface, |
||
| 19 | CliExercise, |
||
| 20 | FunctionRequirementsExerciseCheck |
||
| 21 | { |
||
| 22 | use TemporaryDirectoryTrait; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var Filesystem |
||
| 26 | */ |
||
| 27 | private $filesystem; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var Generator |
||
| 31 | */ |
||
| 32 | private $faker; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @param Filesystem $filesystem |
||
| 36 | * @param Generator $faker |
||
| 37 | */ |
||
| 38 | public function __construct(Filesystem $filesystem, Generator $faker) |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @return string |
||
| 46 | */ |
||
| 47 | public function getName() |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return string |
||
| 54 | */ |
||
| 55 | public function getDescription() |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return array |
||
| 62 | */ |
||
| 63 | public function getArgs() |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @return void |
||
| 84 | */ |
||
| 85 | public function tearDown() |
||
| 89 | |||
| 90 | /** |
||
| 91 | * @return string[] |
||
| 92 | */ |
||
| 93 | public function getRequiredFunctions() |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @return string[] |
||
| 100 | */ |
||
| 101 | public function getBannedFunctions() |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @return ExerciseType |
||
| 108 | */ |
||
| 109 | public function getType() |
||
| 113 | |||
| 114 | /** |
||
| 115 | * @param ExerciseDispatcher $dispatcher |
||
| 116 | */ |
||
| 117 | public function configure(ExerciseDispatcher $dispatcher) |
||
| 121 | } |
||
| 122 |