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 |
||
| 8 | class BaseThemeConfigurationModel extends app\modules\config\models\BaseConfigurationModel |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var bool Should this theme be registered as @theme alias in config |
||
| 12 | */ |
||
| 13 | public $registerThemeAlias = true; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Fills model attributes with default values |
||
| 17 | * @return void |
||
| 18 | */ |
||
| 19 | public function defaultValues() |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Returns array of module configuration that should be stored in application config. |
||
| 26 | * Array should be ready to merge in app config. |
||
| 27 | * Used both for web only. |
||
| 28 | * |
||
| 29 | * @return array |
||
|
|
|||
| 30 | */ |
||
| 31 | public function webApplicationAttributes() |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Returns array of module configuration that should be stored in application config. |
||
| 44 | * Array should be ready to merge in app config. |
||
| 45 | * Used both for console only. |
||
| 46 | * |
||
| 47 | * @return array |
||
| 48 | */ |
||
| 49 | public function consoleApplicationAttributes() |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Returns array of module configuration that should be stored in application config. |
||
| 56 | * Array should be ready to merge in app config. |
||
| 57 | * Used both for web and console. |
||
| 58 | * |
||
| 59 | * @return array |
||
| 60 | */ |
||
| 61 | public function commonApplicationAttributes() |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Returns array of key=>values for configuration. |
||
| 68 | * |
||
| 69 | * @return mixed |
||
| 70 | */ |
||
| 71 | public function keyValueAttributes() |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Returns array of aliases that should be set in common config |
||
| 78 | * @return array |
||
| 79 | */ |
||
| 80 | View Code Duplication | public function aliases() |
|
| 94 | } |
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.