Completed
Push — master ( 8717df...fdbe7f )
by Alexey
05:44
created

Relation   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
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 27
loc 27
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
 * Item option relation
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 Ecommerce\Item\Option;
13
14 View Code Duplication
class Relation extends \Model
15
{
16
    public static $objectName = 'Связь каталога и опций';
17
    public static $cols = [
18
        //Основные параметры
19
        'category_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'category'],
20
        'item_option_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'option'],
21
        //Системные
22
        'weight' => ['type' => 'number'],
23
        'date_create' => ['type' => 'dateTime']
24
    ];
25
26
    public static function relations()
27
    {
28
        return [
29
            'category' => [
30
                'model' => 'Ecommerce\Category',
31
                'col' => 'category_id'
32
            ],
33
            'option' => [
34
                'model' => 'Ecommerce\Item\Option',
35
                'col' => 'item_option_id'
36
            ],
37
        ];
38
    }
39
40
}
41