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 |
||
| 10 | class Cms_base extends CI_Model |
||
| 11 | { |
||
|
|
|||
| 12 | |||
| 13 | public $locale_id; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var array |
||
| 17 | */ |
||
| 18 | private static $settings; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var array |
||
| 22 | */ |
||
| 23 | private static $language; |
||
| 24 | |||
| 25 | public function __construct() { |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Select main settings |
||
| 32 | * |
||
| 33 | * @access public |
||
| 34 | * @param string|null $key |
||
| 35 | * @return array |
||
| 36 | */ |
||
| 37 | public function get_settings($key = null) { |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Select site languages |
||
| 71 | * @access public |
||
| 72 | * @param bool $active |
||
| 73 | * @return array |
||
| 74 | */ |
||
| 75 | public function get_langs($active = FALSE) { |
||
| 95 | |||
| 96 | /** |
||
| 97 | * Load modules |
||
| 98 | */ |
||
| 99 | public function get_modules() { |
||
| 110 | |||
| 111 | /** |
||
| 112 | * @param int $cat_id |
||
| 113 | * @return bool|object |
||
| 114 | */ |
||
| 115 | public function get_category_pages($cat_id) { |
||
| 135 | |||
| 136 | /** |
||
| 137 | * @param bool|int $page_id |
||
| 138 | * @return bool|object |
||
| 139 | */ |
||
| 140 | public function get_page_by_id($page_id = FALSE) { |
||
| 160 | |||
| 161 | /** |
||
| 162 | * @param bool|int $page_id |
||
| 163 | * @return bool|object |
||
| 164 | */ |
||
| 165 | public function get_page($page_id = FALSE) { |
||
| 169 | |||
| 170 | /** |
||
| 171 | * Select all categories |
||
| 172 | * |
||
| 173 | * @access public |
||
| 174 | * @return array |
||
| 175 | */ |
||
| 176 | public function get_categories() { |
||
| 200 | |||
| 201 | /** |
||
| 202 | * @param int $id |
||
| 203 | * @return bool |
||
| 204 | */ |
||
| 205 | View Code Duplication | public function get_category_by_id($id) { |
|
| 222 | |||
| 223 | /** |
||
| 224 | * @param int $id |
||
| 225 | * @return string |
||
| 226 | */ |
||
| 227 | public function get_category_full_path($id) { |
||
| 240 | |||
| 241 | /** |
||
| 242 | * @return array |
||
| 243 | */ |
||
| 244 | public function getCategoriesPagesCounts() { |
||
| 272 | |||
| 273 | /** |
||
| 274 | * @return mixed |
||
| 275 | */ |
||
| 276 | public function getLocaleId() { |
||
| 280 | |||
| 281 | /** |
||
| 282 | * @param mixed $locale_id |
||
| 283 | */ |
||
| 284 | public function setLocaleId($locale_id) { |
||
| 293 | |||
| 294 | } |
||
| 295 | |||
| 296 | /* end of cms_base.php */ |