Currency   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 100
Duplicated Lines 9 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 1
dl 9
loc 100
ccs 42
cts 63
cp 0.6667
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getYmlBody() 0 4 1
A rules() 0 47 1
A getYmlEndTag() 0 4 1
A getYmlStartTag() 9 9 2

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
class Currency extends BaseModel
5
{
6
    /**
7
     * @inheritdoc
8
     */
9
    public static $tag = 'currency';
10
11
    /**
12
     * @inheritdoc
13
     */
14
    public static $tagProperties = [
15
        'id',
16
        'rate',
17
        'plus',
18
    ];
19
20
    public $id;
21
    public $rate;
22
    public $plus;
23
24
    /**
25
     * @inheritdoc
26
     */
27 5
    public function rules()
28
    {
29
        return [
30
            [
31
                [
32 5
                    'id',
33 5
                    'rate',
34 5
                ],
35 5
                'required',
36 5
            ],
37
            [
38
                [
39 5
                    'rate',
40 5
                ],
41 5
                'string',
42 5
                'max' => 5,
43 5
            ],
44
            [
45
                [
46 5
                    'id',
47 5
                ],
48 5
                'string',
49 5
                'max' => 3,
50 5
            ],
51
            [
52
                [
53 5
                    'plus',
54 5
                ],
55 5
                'integer',
56 5
            ],
57
            [
58
                [
59 5
                    'id',
60 5
                ],
61 5
                'in',
62
                'range' => [
63 5
                    'RUR',
64 5
                    'RUB',
65 5
                    'UAH',
66 5
                    'BYR',
67 5
                    'KZT',
68 5
                    'USD',
69
                    'EUR'
70 5
                ],
71 5
            ],
72 5
        ];
73
    }
74
75
    /**
76
     * @inheritdoc
77
     */
78 5
    protected function getYmlBody()
79
    {
80 5
        return null;
81
    }
82
    
83
    /**
84
     * @return string
85
     */
86 5
    protected function getYmlEndTag()
87
    {
88 5
        return '';
89
    }
90
91
    /**
92
     * @return string
93
     */
94 5 View Code Duplication
    protected function getYmlStartTag()
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...
95
    {
96 5
        $string = '';
97 5
        if (static::$tag) {
98 5
            $string = '<' . static::$tag . $this->getYmlTagProperties() . ' />';
99 5
        }
100
101 5
        return $string;
102
    }
103
}
104