Completed
Push — master ( 594f71...a14e49 )
by Alexey
05:31
created

Data   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 40
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 40
loc 40
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A relations() 9 9 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
 * City data model
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 Geography\City;
13
14 View Code Duplication
class Data extends \Model
15
{
16
    public static $objectName = 'Данные города';
17
    public static $labels = [
18
        'code' => 'Код',
19
        'data' => 'Данные',
20
        'city_id' => 'Город',
21
        'date_create' => 'Дата создания',
22
    ];
23
    public static $cols = [
24
        'code' => ['type' => 'text'],
25
        'data' => ['type' => 'textarea'],
26
        'city_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'city'],
27
        'date_create' => ['type'=>'dateTime'],
28
    ];
29
    public static $dataManagers = [
30
        'manager' => [
31
            'cols' => ['code', 'data', 'date_create']
32
        ]
33
    ];
34
    public static $forms = [
35
        'manager' => [
36
            'map' => [
37
                ['code', 'city_id'],
38
                ['data']
39
            ]
40
        ]
41
    ];
42
43
    public static function relations()
44
    {
45
        return [
46
            'city' => [
47
                'model' => 'Geography\City',
48
                'col' => 'city_id'
49
            ],
50
        ];
51
    }
52
53
}
54