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 friends 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 = 'FRIENDS'; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Default module-image: |
||
| 34 | * file must be in "{T_THEME_PATH}/images/portal/" |
||
| 35 | */ |
||
| 36 | public $image_src = 'portal_friends.png'; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * module-language file |
||
| 40 | * file must be in "language/{$user->lang}/mods/portal/" |
||
| 41 | */ |
||
| 42 | public $language = 'portal_friends_module'; |
||
| 43 | |||
| 44 | /** @var \phpbb\auth\auth */ |
||
| 45 | protected $auth; |
||
| 46 | |||
| 47 | /** @var \phpbb\config\config */ |
||
| 48 | protected $config; |
||
| 49 | |||
| 50 | /** @var \phpbb\db\driver */ |
||
| 51 | protected $db; |
||
| 52 | |||
| 53 | /** @var \phpbb\template */ |
||
| 54 | protected $template; |
||
| 55 | |||
| 56 | /** @var \phpbb\user */ |
||
| 57 | protected $user; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Construct a friends object |
||
| 61 | * |
||
| 62 | * @param \phpbb\auth\auth $auth phpBB auth service |
||
| 63 | * @param \phpbb\config\config $config phpBB config |
||
| 64 | * @param \phpbb\db\driver $db phpBB db driver |
||
| 65 | * @param \phpbb\template $template phpBB template |
||
| 66 | * @param \phpbb\user $user phpBB user object |
||
| 67 | */ |
||
| 68 | View Code Duplication | public function __construct($auth, $config, $db, $template, $user) |
|
| 76 | |||
| 77 | /** |
||
| 78 | * {@inheritdoc} |
||
| 79 | */ |
||
| 80 | public function get_template_side($module_id) |
||
| 132 | |||
| 133 | /** |
||
| 134 | * {@inheritdoc} |
||
| 135 | */ |
||
| 136 | View Code Duplication | public function get_template_acp($module_id) |
|
| 146 | |||
| 147 | /** |
||
| 148 | * {@inheritdoc} |
||
| 149 | */ |
||
| 150 | public function install($module_id) |
||
| 155 | |||
| 156 | /** |
||
| 157 | * {@inheritdoc} |
||
| 158 | */ |
||
| 159 | View Code Duplication | public function uninstall($module_id, $db) |
|
| 168 | } |
||
| 169 |