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 | 'delivery_field_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'field'],  | 
            ||
| 20 | 'value' => ['type' => 'text'],  | 
            ||
| 21 | //Системные  | 
            ||
| 22 | 'weight' => ['type' => 'number'],  | 
            ||
| 23 | 'date_create' => ['type' => 'dateTime']  | 
            ||
| 24 | ];  | 
            ||
| 25 | public static $labels = [  | 
            ||
| 26 | 'value' => 'Значение'  | 
            ||
| 27 | ];  | 
            ||
| 28 | public static $dataManagers = [  | 
            ||
| 29 | 'manager' => [  | 
            ||
| 30 | 'cols' => ['value', 'date_create']  | 
            ||
| 31 | ]  | 
            ||
| 32 | ];  | 
            ||
| 33 | public static $forms = [  | 
            ||
| 34 | 'manager' => [  | 
            ||
| 35 | 'map' => [  | 
            ||
| 36 | ['delivery_field_id', 'value']  | 
            ||
| 37 | ]  | 
            ||
| 38 | ]  | 
            ||
| 39 | ];  | 
            ||
| 40 | |||
| 41 | function name()  | 
            ||
| 45 | |||
| 46 | public static function relations()  | 
            ||
| 55 | |||
| 56 | }  | 
            ||
| 57 | 
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.