Completed
Push — master ( 51e7b9...4b0341 )
by Alexey
05:48
created

DeliveryInfo   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 50
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 50
loc 50
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A relations() 13 13 1

How to fix   Duplicated Code   

Duplicated Code

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
2
3
/**
4
 * Delivery user info
5
 * @author Alexey Krupskiy <[email protected]>
6
 * @link http://inji.ru/
7
 * @copyright 2016 Alexey Krupskiy
8
 * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE
9
 */
10
11
namespace Ecommerce\Cart;
12
13 View Code Duplication
class DeliveryInfo extends \Model
14
{
15
    public static $objectName = 'Информация о доставке';
16
    public static $labels = [
17
        'name' => 'Название',
18
        'cart_id' => 'Корзина',
19
        'delivery_field_id' => 'Поле',
20
        'value' => 'Значение',
21
    ];
22
    public static $cols = [
23
        //Основные параметры
24
        'name' => ['type' => 'text'],
25
        'cart_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'cart'],
26
        'delivery_field_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'field'],
27
        'value' => ['type' => 'text'],
28
        //Системные
29
        'date_create' => ['type' => 'dateTime'],
30
    ];
31
    public static $forms = [
32
        'manager' => [
33
            'map' => [
34
                ['name', 'value'],
35
                ['delivery_field_id', 'cart_id'],
36
            ]
37
        ]
38
    ];
39
    public static $dataManagers = [
40
        'manager' => [
41
            'cols' => [
42
                'name',
43
                'value'
44
            ]
45
        ]
46
    ];
47
48
    public static function relations()
49
    {
50
        return [
51
            'field' => [
52
                'model' => 'Ecommerce\Delivery\Field',
53
                'col' => 'delivery_field_id'
54
            ],
55
            'cart' => [
56
                'model' => 'Ecommerce\Cart',
57
                'col' => 'cart_id'
58
            ],
59
        ];
60
    }
61
62
}
63