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 stylechanger 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 = 'BOARD_STYLE'; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Default module-image: |
||
| 34 | * file must be in "{T_THEME_PATH}/images/portal/" |
||
| 35 | */ |
||
| 36 | public $image_src = 'portal_style.png'; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * module-language file |
||
| 40 | * file must be in "language/{$user->lang}/mods/portal/" |
||
| 41 | */ |
||
| 42 | public $language = 'portal_stylechanger_module'; |
||
| 43 | |||
| 44 | /** @var \phpbb\config\config */ |
||
| 45 | protected $config; |
||
| 46 | |||
| 47 | /** @var \board3\portal\includes\modules_helper */ |
||
| 48 | protected $modules_helper; |
||
| 49 | |||
| 50 | /** @var \phpbb\template\template */ |
||
| 51 | protected $template; |
||
| 52 | |||
| 53 | /** @var \phpbb\db\driver\driver_interface */ |
||
| 54 | protected $db; |
||
| 55 | |||
| 56 | /** @var \phpbb\request\request_interface */ |
||
| 57 | protected $request; |
||
| 58 | |||
| 59 | /** @var \phpbb\user */ |
||
| 60 | protected $user; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Construct a stylechanger object |
||
| 64 | * |
||
| 65 | * @param \phpbb\config\config $config phpBB config |
||
| 66 | * @param \board3\portal\includes\modules_helper $modules_helper Modules helper |
||
| 67 | * @param \phpbb\template\template $template phpBB template |
||
| 68 | * @param \phpbb\db\driver\driver_interface $db Database driver |
||
| 69 | * @param \phpbb\request\request_interface $request phpBB request |
||
| 70 | * @param \phpbb\user $user phpBB user object |
||
| 71 | */ |
||
| 72 | View Code Duplication | public function __construct($config, $modules_helper, $template, $db, $request, $user) |
|
| 81 | |||
| 82 | /** |
||
| 83 | * {@inheritdoc} |
||
| 84 | */ |
||
| 85 | public function get_template_side($module_id) |
||
| 121 | |||
| 122 | /** |
||
| 123 | * {@inheritdoc} |
||
| 124 | */ |
||
| 125 | public function get_template_acp($module_id) |
||
| 132 | } |
||
| 133 |