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_members 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_MEMBERS'; |
||
31 | |||
32 | /** |
||
33 | * Default module-image: |
||
34 | * file must be in "{T_THEME_PATH}/images/portal/" |
||
35 | */ |
||
36 | public $image_src = 'portal_members.png'; |
||
37 | |||
38 | /** |
||
39 | * module-language file |
||
40 | * file must be in "language/{$user->lang}/mods/portal/" |
||
41 | */ |
||
42 | public $language = 'portal_latest_members_module'; |
||
43 | |||
44 | /** @var \phpbb\config\config */ |
||
45 | protected $config; |
||
46 | |||
47 | /** @var \phpbb\db\driver\driver_interface */ |
||
48 | protected $db; |
||
49 | |||
50 | /** @var \phpbb\template\template */ |
||
51 | protected $template; |
||
52 | |||
53 | /** @var \phpbb\user */ |
||
54 | protected $user; |
||
55 | |||
56 | /** |
||
57 | * Construct a latest_members object |
||
58 | * |
||
59 | * @param \phpbb\config\config $config phpBB config |
||
60 | * @param \phpbb\db\driver\driver_interface $db phpBB db driver |
||
61 | * @param \phpbb\template\template $template phpBB template |
||
62 | * @param \phpbb\user $user phpBB user object |
||
63 | */ |
||
64 | View Code Duplication | public function __construct($config, $db, $template, $user) |
|
71 | |||
72 | /** |
||
73 | * {@inheritdoc} |
||
74 | */ |
||
75 | public function get_template_side($module_id) |
||
95 | |||
96 | /** |
||
97 | * {@inheritdoc} |
||
98 | */ |
||
99 | View Code Duplication | public function get_template_acp($module_id) |
|
109 | |||
110 | /** |
||
111 | * {@inheritdoc} |
||
112 | */ |
||
113 | public function install($module_id) |
||
118 | |||
119 | /** |
||
120 | * {@inheritdoc} |
||
121 | */ |
||
122 | View Code Duplication | public function uninstall($module_id, $db) |
|
131 | } |
||
132 |