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 Price extends \Model { |
|
15 | |||
16 | public static $labels = [ |
||
17 | 'delivery_id' => 'Тип доставки', |
||
18 | 'cart_price' => 'Сумма корзины', |
||
19 | 'price' => 'Стоимость доставки', |
||
20 | 'currency_id' => 'Валюта', |
||
21 | ]; |
||
22 | public static $cols = [ |
||
23 | 'delivery_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'delivery'], |
||
24 | 'cart_price' => ['type' => 'number'], |
||
25 | 'price' => ['type' => 'number'], |
||
26 | 'currency_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'currency'], |
||
27 | 'date_create' => ['type' => 'dateTime'] |
||
28 | ]; |
||
29 | public static $dataManagers = [ |
||
30 | 'manager' => [ |
||
31 | 'name' => 'Цены для стоимости корзин', |
||
32 | 'cols' => ['delivery_id', 'cart_price', 'price', 'currency_id'], |
||
33 | ] |
||
34 | ]; |
||
35 | public static $forms = [ |
||
36 | 'manager' => [ |
||
37 | 'map' => [ |
||
38 | ['delivery_id', 'currency_id'], |
||
39 | ['cart_price', 'price'], |
||
40 | ] |
||
41 | ] |
||
42 | ]; |
||
43 | |||
44 | public static function relations() { |
||
56 | |||
57 | } |
||
58 |