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 |
||
12 | class ScriptManager |
||
13 | { |
||
14 | private $tasks; |
||
15 | private $hooksEnabled = true; |
||
16 | |||
17 | 5 | public function __construct(TaskCollection $tasks) |
|
21 | |||
22 | /** |
||
23 | * Return tasks to run. |
||
24 | * |
||
25 | * @return Task[] |
||
26 | */ |
||
27 | 5 | public function getTasks(string $name) |
|
55 | |||
56 | public function getHooksEnabled() |
||
60 | |||
61 | public function setHooksEnabled($hooksEnabled): void |
||
65 | } |
||
66 |