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 |
||
| 13 | View Code Duplication | class Value extends \Model |
|
| 14 | { |
||
| 15 | public static $cols = [ |
||
| 16 | //Основные параметры |
||
| 17 | 'delivery_save_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'save'], |
||
| 18 | 'delivery_field_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'field'], |
||
| 19 | 'value' => ['type' => 'text'], |
||
| 20 | //Системные |
||
| 21 | 'date_create' => ['type' => 'dateTime'], |
||
| 22 | ]; |
||
| 23 | public static $forms = [ |
||
| 24 | 'manager' => [ |
||
| 25 | 'map' => [ |
||
| 26 | ['cart_id', 'delivery_field_id', 'value'] |
||
| 27 | ] |
||
| 28 | ] |
||
| 29 | ]; |
||
| 30 | public static $dataManagers = [ |
||
| 31 | 'manager' => [ |
||
| 32 | 'cols' => [ |
||
| 33 | 'cart_id', |
||
| 34 | 'delivery_field_id', |
||
| 35 | 'value' |
||
| 36 | ] |
||
| 37 | ] |
||
| 38 | ]; |
||
| 39 | |||
| 40 | public static function relations() |
||
| 53 | |||
| 54 | } |
||
| 55 |