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

Country   A

Complexity

Total Complexity 1

Size/Duplication

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

1 Method

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