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 latest_bots 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 = 'LATEST_BOTS'; |
||
31 | |||
32 | /** |
||
33 | * Default module-image: |
||
34 | * file must be in "{T_THEME_PATH}/images/portal/" |
||
35 | */ |
||
36 | public $image_src = 'portal_bots.png'; |
||
37 | |||
38 | /** |
||
39 | * module-language file |
||
40 | * file must be in "language/{$user->lang}/mods/portal/" |
||
41 | */ |
||
42 | public $language = 'portal_latest_bots_module'; |
||
43 | |||
44 | /** |
||
45 | * hide module name in ACP configuration page |
||
46 | */ |
||
47 | public $hide_name = false; |
||
48 | |||
49 | /** @var \phpbb\config\config */ |
||
50 | protected $config; |
||
51 | |||
52 | /** @var \phpbb\db\driver\driver_interface */ |
||
53 | protected $db; |
||
54 | |||
55 | /** @var \phpbb\template\template */ |
||
56 | protected $template; |
||
57 | |||
58 | /** @var \phpbb\user */ |
||
59 | protected $user; |
||
60 | |||
61 | /** |
||
62 | * Construct a latest bots object |
||
63 | * |
||
64 | * @param \phpbb\config\config $config phpBB config |
||
65 | * @param \phpbb\db\driver\driver_interface $db phpBB db driver |
||
66 | * @param \phpbb\template\template $template phpBB template |
||
67 | * @param \phpbb\user $user phpBB user object |
||
68 | */ |
||
69 | View Code Duplication | public function __construct($config, $db, $template, $user) |
|
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | public function get_template_side($module_id) |
||
107 | |||
108 | /** |
||
109 | * {@inheritdoc} |
||
110 | */ |
||
111 | View Code Duplication | public function get_template_acp($module_id) |
|
121 | |||
122 | /** |
||
123 | * {@inheritdoc} |
||
124 | */ |
||
125 | public function install($module_id) |
||
130 | |||
131 | /** |
||
132 | * {@inheritdoc} |
||
133 | */ |
||
134 | View Code Duplication | public function uninstall($module_id, $db) |
|
143 | } |
||
144 |