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 namespace Modules\Setting\Repositories\Cache; |
||
| 6 | class CacheSettingDecorator extends BaseCacheDecorator implements SettingRepository |
||
| 7 | { |
||
| 8 | public function __construct(SettingRepository $setting) |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Create or update the settings |
||
| 17 | * @param $settings |
||
| 18 | * @return mixed |
||
| 19 | */ |
||
| 20 | public function createOrUpdate($settings) |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Find a setting by its name |
||
| 29 | * @param $settingName |
||
| 30 | * @return mixed |
||
| 31 | */ |
||
| 32 | View Code Duplication | public function findByName($settingName) |
|
| 42 | |||
| 43 | /** |
||
| 44 | * Return all modules that have settings |
||
| 45 | * with its settings |
||
| 46 | * @param array|string $modules |
||
| 47 | * @return array |
||
| 48 | */ |
||
| 49 | View Code Duplication | public function moduleSettings($modules) |
|
| 61 | |||
| 62 | /** |
||
| 63 | * Return the saved module settings |
||
| 64 | * @param $module |
||
| 65 | * @return mixed |
||
| 66 | */ |
||
| 67 | View Code Duplication | public function savedModuleSettings($module) |
|
| 77 | |||
| 78 | /** |
||
| 79 | * Find settings by module name |
||
| 80 | * @param string $module |
||
| 81 | * @return mixed |
||
| 82 | */ |
||
| 83 | View Code Duplication | public function findByModule($module) |
|
| 93 | |||
| 94 | /** |
||
| 95 | * Find the given setting name for the given module |
||
| 96 | * @param string $settingName |
||
| 97 | * @return mixed |
||
| 98 | */ |
||
| 99 | View Code Duplication | public function get($settingName) |
|
| 109 | |||
| 110 | /** |
||
| 111 | * Return the translatable module settings |
||
| 112 | * @param $module |
||
| 113 | * @return array |
||
| 114 | */ |
||
| 115 | View Code Duplication | public function translatableModuleSettings($module) |
|
| 125 | |||
| 126 | /** |
||
| 127 | * Return the non translatable module settings |
||
| 128 | * @param $module |
||
| 129 | * @return array |
||
| 130 | */ |
||
| 131 | View Code Duplication | public function plainModuleSettings($module) |
|
| 141 | } |
||
| 142 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.