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 |
||
14 | View Code Duplication | class Item extends \Model { |
|
15 | |||
16 | public static $objectName = 'Элемент коллекции поля формы'; |
||
17 | public static $cols = [ |
||
18 | //Основные параметры |
||
19 | 'useradds_field_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'field'], |
||
20 | 'value' => ['type' => 'text'], |
||
21 | 'data' => ['type' => 'textarea'], |
||
22 | //Системные |
||
23 | 'weight' => ['type' => 'number'], |
||
24 | 'date_create' => ['type' => 'dateTime'] |
||
25 | ]; |
||
26 | public static $labels = [ |
||
27 | 'value' => 'Значение', |
||
28 | 'data' => 'Дополнительные данные', |
||
29 | ]; |
||
30 | public static $dataManagers = [ |
||
31 | 'manager' => [ |
||
32 | 'cols' => ['value', 'data', 'date_create'] |
||
33 | ] |
||
34 | ]; |
||
35 | public static $forms = [ |
||
36 | 'manager' => [ |
||
37 | 'map' => [ |
||
38 | ['value', 'data'] |
||
39 | ] |
||
40 | ] |
||
41 | ]; |
||
42 | |||
43 | public function name() { |
||
46 | |||
47 | public static function relations() { |
||
55 | |||
56 | } |
||
57 |