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 |
||
15 | class clock extends module_base |
||
16 | { |
||
17 | /** |
||
18 | * Allowed columns: Just sum up your options (Exp: left + right = 10) |
||
19 | * top 1 |
||
20 | * left 2 |
||
21 | * center 4 |
||
22 | * right 8 |
||
23 | * bottom 16 |
||
24 | */ |
||
25 | public $columns = 10; |
||
26 | |||
27 | /** |
||
28 | * Default modulename |
||
29 | */ |
||
30 | public $name = 'CLOCK'; |
||
31 | |||
32 | /** |
||
33 | * Default module-image: |
||
34 | * file must be in "{T_THEME_PATH}/images/portal/" |
||
35 | */ |
||
36 | public $image_src = 'portal_clock.png'; |
||
37 | |||
38 | /** |
||
39 | * module-language file |
||
40 | * file must be in "language/{$user->lang}/mods/portal/" |
||
41 | */ |
||
42 | public $language = 'portal_clock_module'; |
||
43 | |||
44 | /** @var \phpbb\config\config */ |
||
45 | protected $config; |
||
46 | |||
47 | /** @var \phpbb\template\template */ |
||
48 | protected $template; |
||
49 | |||
50 | /** |
||
51 | * Constructor for clock module |
||
52 | * |
||
53 | * @param \phpbb\config\config $config phpBB config |
||
54 | * @param \phpbb\template\template $template phpBB template |
||
55 | */ |
||
56 | 49 | public function __construct($config, $template) |
|
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | 4 | public function get_template_side($module_id) |
|
73 | |||
74 | /** |
||
75 | * {@inheritdoc} |
||
76 | */ |
||
77 | 1 | View Code Duplication | public function get_template_acp($module_id) |
87 | |||
88 | /** |
||
89 | * {@inheritdoc} |
||
90 | */ |
||
91 | 1 | public function install($module_id) |
|
96 | |||
97 | /** |
||
98 | * {@inheritdoc} |
||
99 | */ |
||
100 | 1 | public function uninstall($module_id, $db) |
|
105 | } |
||
106 |