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 |
||
| 22 | class SeoHelper extends MY_Controller |
||
| 23 | { |
||
|
|
|||
| 24 | |||
| 25 | protected static $_instance; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * __construct base object loaded |
||
| 29 | * @access public |
||
| 30 | * @author DevImageCms |
||
| 31 | * @copyright (c) 2013, ImageCMS |
||
| 32 | */ |
||
| 33 | public function __construct() { |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @return SeoHelper |
||
| 43 | */ |
||
| 44 | public static function create() { |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Prepare parent category name (in future all categories in full path) |
||
| 51 | * @param bool|int $categoryId |
||
| 52 | * @param bool|string $locale |
||
| 53 | * @return array|bool - parentCategory |
||
| 54 | */ |
||
| 55 | public function prepareCategoriesForProductCategory($categoryId = false, $locale = false) { |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Autocomplete categories |
||
| 68 | * @return jsone |
||
| 69 | */ |
||
| 70 | public function autoCompleteCategories() { |
||
| 88 | |||
| 89 | /** |
||
| 90 | * Get base settings |
||
| 91 | * @param bool|string $locale |
||
| 92 | * @return array|bool |
||
| 93 | */ |
||
| 94 | View Code Duplication | public function getBaseSettings($locale = FALSE) { |
|
| 106 | |||
| 107 | /** |
||
| 108 | * |
||
| 109 | * @param bool|string $locale |
||
| 110 | * @param bool|array $settings |
||
| 111 | * @return bool |
||
| 112 | */ |
||
| 113 | View Code Duplication | public function setBaseSettings($locale = FALSE, $settings = FALSE) { |
|
| 126 | |||
| 127 | } |