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 | 'item_option_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'option'], |
||
| 20 | 'value' => ['type' => 'text'], |
||
| 21 | //Системные |
||
| 22 | 'weight' => ['type' => 'number'], |
||
| 23 | 'date_create' => ['type' => 'dateTime'] |
||
| 24 | ]; |
||
| 25 | public static $labels = [ |
||
| 26 | 'value' => 'Значение' |
||
| 27 | ]; |
||
| 28 | |||
| 29 | public static function relations() |
||
| 38 | |||
| 39 | } |
||
| 40 |