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 |
||
29 | View Code Duplication | class VRmodeUIComponent extends ComponentAbstract implements VRmodeUICMPTIF |
|
|
|||
30 | { |
||
31 | |||
32 | /** |
||
33 | * Initialize Component |
||
34 | * |
||
35 | * {@inheritdoc} |
||
36 | * |
||
37 | * @return bool |
||
38 | */ |
||
39 | 1 | public function initializeComponent(): bool |
|
45 | |||
46 | /** |
||
47 | * look-controls enabled |
||
48 | * |
||
49 | * {@inheritdoc} |
||
50 | * |
||
51 | * @param bool $enabled |
||
52 | * @return VRmodeUICMPTIF |
||
53 | */ |
||
54 | 1 | public function enabled(bool $enabled = true): VRmodeUICMPTIF |
|
59 | |||
60 | /** |
||
61 | * Does component have DOM Atributes |
||
62 | * |
||
63 | * If compnent is called then we return true |
||
64 | * |
||
65 | * {@inheritdoc} |
||
66 | * |
||
67 | * @return bool |
||
68 | */ |
||
69 | 1 | public function hasDOMAttributes(): bool |
|
73 | } |
||
74 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.