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 topposters 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 = 'TOPPOSTERS'; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Default module-image: |
||
| 34 | * file must be in "{T_THEME_PATH}/images/portal/" |
||
| 35 | */ |
||
| 36 | public $image_src = 'portal_top_poster.png'; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * module-language file |
||
| 40 | * file must be in "language/{$user->lang}/mods/portal/" |
||
| 41 | */ |
||
| 42 | public $language = 'portal_topposters_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 string PHP file extension */ |
||
| 54 | protected $php_ext; |
||
| 55 | |||
| 56 | /** @var string phpBB root path */ |
||
| 57 | protected $phpbb_root_path; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Construct a topposers object |
||
| 61 | * |
||
| 62 | * @param \phpbb\config\config $config phpBB config |
||
| 63 | * @param \phpbb\db\driver\driver_interface $db phpBB db driver |
||
| 64 | * @param \phpbb\template\template $template phpBB template |
||
| 65 | * @param string $phpbb_root_path phpBB root path |
||
| 66 | * @param string $phpEx php file extension |
||
| 67 | */ |
||
| 68 | public function __construct($config, $db, $template, $phpbb_root_path, $phpEx) |
||
| 76 | |||
| 77 | /** |
||
| 78 | * {@inheritdoc} |
||
| 79 | */ |
||
| 80 | public function get_template_side($module_id) |
||
| 102 | |||
| 103 | /** |
||
| 104 | * {@inheritdoc} |
||
| 105 | */ |
||
| 106 | public function get_template_acp($module_id) |
||
| 116 | |||
| 117 | /** |
||
| 118 | * {@inheritdoc} |
||
| 119 | */ |
||
| 120 | public function install($module_id) |
||
| 125 | |||
| 126 | /** |
||
| 127 | * {@inheritdoc} |
||
| 128 | */ |
||
| 129 | View Code Duplication | public function uninstall($module_id, $db) |
|
| 138 | } |
||
| 139 |