Completed
Pull Request — master (#3)
by
unknown
05:51
created

Activity   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 45
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 45
loc 45
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
 * Role
5
 *
6
 * @author Alexey Krupskiy <[email protected]>
7
 * @link http://inji.ru/
8
 * @copyright 2015 Alexey Krupskiy
9
 * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE
10
 */
11
12
namespace Users;
13
14 View Code Duplication
class Activity extends \Model
15
{
16
    public static $objectName = 'Activity';
17
    public static $labels = [
18
        'text' => 'Текст',
19
        'user_id' => 'Пользователь',
20
        'category_id' => 'Категория',
21
    ];
22
    public static $cols = [
23
        'text' => ['type' => 'text'],
24
        'user_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'user'],
25
        'category_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'category'],
26
    ];
27
    public static $dataManagers = [
28
        'manager' => [
29
            'name' => 'Activity',
30
            'cols' => [
31
                'text', 'user_id', 'category_id', 'date_create',
32
            ]
33
        ]
34
    ];
35
    public static $forms = [
36
        'manager' => [
37
            'map' => [
38
                ['text'],
39
                ['user_id', 'category_id']
40
            ]
41
        ]
42
    ];
43
44
    public static function relations()
45
    {
46
        return [
47
            'user' => [
48
                'model' => 'Users\User',
49
                'col' => 'user_id'
50
            ],
51
            'category' => [
52
                'model' => 'Users\Activity\Category',
53
                'col' => 'category_id'
54
            ],
55
        ];
56
    }
57
58
}
59