Completed
Push — master ( 6cd982...18aa30 )
by Alexey
05:03
created

Price   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 44
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 44
loc 44
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A relations() 12 12 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
 * Link between delivery and link
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\Delivery;
13
14 View Code Duplication
class Price extends \Model {
15
16
  public static $labels = [
17
      'delivery_id' => 'Тип доставки',
18
      'cart_price' => 'Сумма корзины',
19
      'price' => 'Стоимость доставки',
20
      'currency_id' => 'Валюта',
21
  ];
22
  public static $cols = [
23
      'delivery_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'delivery'],
24
      'cart_price' => ['type' => 'number'],
25
      'price' => ['type' => 'number'],
26
      'currency_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'currency'],
27
      'date_create' => ['type' => 'dateTime']
28
  ];
29
  public static $dataManagers = [
30
      'manager' => [
31
          'name' => 'Цены для стоимости корзин',
32
          'cols' => ['delivery_id', 'cart_price', 'price', 'currency_id'],
33
      ]
34
  ];
35
  public static $forms = [
36
      'manager' => [
37
          'map' => [
38
              ['delivery_id', 'currency_id'],
39
              ['cart_price', 'price'],
40
          ]
41
      ]
42
  ];
43
44
  public static function relations() {
45
    return [
46
        'delivery' => [
47
            'model' => 'Ecommerce\Delivery',
48
            'col' => 'delivery_id'
49
        ],
50
        'currency' => [
51
            'model' => 'Money\Currency',
52
            'col' => 'currency_id'
53
        ],
54
    ];
55
  }
56
57
}
58