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 |
||
13 | class m1_hide_ad_for_group extends \phpbb\db\migration\container_aware_migration |
||
14 | { |
||
15 | /** |
||
16 | * {@inheritDoc} |
||
17 | */ |
||
18 | public function effectively_installed() |
||
22 | |||
23 | /** |
||
24 | * {@inheritDoc} |
||
25 | */ |
||
26 | public static function depends_on() |
||
34 | |||
35 | /** |
||
36 | * Add the ad_group table |
||
37 | * |
||
38 | * @return array Array of table schema |
||
39 | * @access public |
||
40 | */ |
||
41 | View Code Duplication | public function update_schema() |
|
55 | |||
56 | /** |
||
57 | * Drop the ad_group table |
||
58 | * |
||
59 | * @return array Array of table schema |
||
60 | * @access public |
||
61 | */ |
||
62 | public function revert_schema() |
||
70 | |||
71 | /** |
||
72 | * Remove phpbb_ads_hide_groups config. |
||
73 | * |
||
74 | * @return array Array of data update instructions |
||
75 | */ |
||
76 | public function update_data() |
||
83 | |||
84 | /** |
||
85 | * Convert hide_groups config value into rows in ad_group table |
||
86 | */ |
||
87 | public function convert_hide_groups() |
||
108 | } |
||
109 |
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.