DeliveryOption   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 71
Duplicated Lines 25.35 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 1
dl 18
loc 71
ccs 18
cts 30
cp 0.6
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getYmlBody() 0 4 1
A getYmlStartTag() 0 4 1
A getYmlEndTag() 0 4 1
A rules() 18 18 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
namespace pastuhov\ymlcatalog\models;
3
4
/**
5
 * Class DeliveryOption
6
 *
7
 * Модель опции условий доставки - тега option в секции delivery-option
8
 * @package pastuhov\ymlcatalog\models
9
 */
10
class DeliveryOption extends BaseModel
11
{
12
    /**
13
     * @inheritdoc
14
     */
15
    public static $tag = 'option';
16
17
    /**
18
     * @inheritdoc
19
     */
20
    public static $tagProperties = [
21
        'cost',
22
        'days',
23
        'orderBefore' => 'order-before'
24
    ];
25
26
    /** @var int Стоимость доставки в рублях. */
27
    public $cost;
28
29
    /** @var string Срок доставки в рабочих днях. */
30
    public $days;
31
32
    /** @var int Время, до которого нужно сделать заказ, чтобы получить его в этот срок. */
33
    public $orderBefore;
34 4
35
    /**
36
     * @inheritdoc
37
     */
38 4 View Code Duplication
    public function rules()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39 4
    {
40 4
        return [
41
            [
42 4
                ['cost', 'days'],
43 4
                'required',
44 4
            ],
45
            [
46 4
                ['cost', 'orderBefore'],
47 4
                'integer',
48 4
            ],
49 4
            [
50 4
                ['days'],
51
                'string',
52
                'max' => 5,
53
            ],
54
        ];
55
    }
56 4
57
    /**
58 4
     * @inheritdoc
59
     */
60
    protected function getYmlBody()
61
    {
62
        return null;
63
    }
64 4
65
    /**
66 4
     * @return string
67
     */
68
    protected function getYmlStartTag()
69
    {
70
        return str_replace('>', ' />', parent::getYmlStartTag());
71
    }
72 4
73
    /**
74 4
     * @return string
75
     */
76
    protected function getYmlEndTag()
77
    {
78
        return '';
79
    }
80
}
81