Completed
Push — master ( faf894...f88301 )
by Alexey
05:18
created

Stage   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 42
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

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
 * Ecommerce cart stage
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\Cart;
13
14 View Code Duplication
class Stage extends \Model
15
{
16
    public static $objectName = 'Этап наполнения корзины';
17
    public static $cols = [
18
        'sum' => ['type' => 'decimal'],
19
        'currency_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'currency'],
20
        'type' => ['type' => 'select', 'source' => 'array', 'sourceArray' => ['discount' => 'Скидка']],
21
        'value' => ['type' => 'text'],
22
        'group' => ['type' => 'text']
23
    ];
24
    public static $labels = [
25
        'sum' => 'Сумма',
26
        'type' => 'Тип',
27
        'group' => 'Группа',
28
        'currency_id' => 'Валюта',
29
        'value' => 'Значение'
30
    ];
31
    public static $dataManagers = [
32
        'manager' => [
33
            'cols' => ['sum', 'currency_id', 'type', 'value', 'group']
34
        ]
35
    ];
36
    public static $forms = [
37
        'manager' => [
38
            'map' => [
39
                ['sum', 'currency_id'],
40
                ['type', 'value', 'group']
41
            ]
42
        ]
43
    ];
44
45
    public static function relations()
46
    {
47
        return [
48
            'currency' => [
49
                'model' => 'Money\Currency',
50
                'col' => 'currency_id'
51
            ]
52
        ];
53
    }
54
55
}
56