Test Failed
Push — master ( 249f62...0357c9 )
by Alexey
05:01
created

CityLink   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 42
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 42
loc 42
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A relations() 12 12 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
 * Link between delivery and link
5
 *
6
 * @author Alexey Krupskiy <[email protected]>
7
 * @link http://inji.ru/
8
 * @copyright 2016 Alexey Krupskiy
9
 * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE
10
 */
11
12
namespace Ecommerce\Delivery;
13
14 View Code Duplication
class CityLink extends \Model {
15
16
    public static $labels = [
17
        'delivery_id' => 'Тип доставки',
18
        'city_id' => 'Город',
19
        'date_create' => 'Дата создания'
20
    ];
21
    public static $cols = [
22
        'delivery_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'delivery'],
23
        'city_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'city'],
24
        'weight' => ['type' => 'number'],
25
        'date_create' => ['type' => 'dateTime']
26
    ];
27
    public static $dataManagers = [
28
        'manager' => [
29
            'name' => 'Города доставки',
30
            'cols' => ['city_id', 'date_create'],
31
            'sortMode' => true
32
        ]
33
    ];
34
    public static $forms = [
35
        'manager' => [
36
            'map' => [
37
                ['delivery_id', 'city_id'],
38
            ]
39
        ]
40
    ];
41
42
    public static function relations() {
43
        return [
44
            'city' => [
45
                'model' => 'Geography\City',
46
                'col' => 'city_id'
47
            ],
48
            'delivery' => [
49
                'model' => 'Ecommerce\Delivery',
50
                'col' => 'delivery_id'
51
            ],
52
        ];
53
    }
54
55
}
56