Completed
Pull Request — master (#39)
by
unknown
05:19 queued 02:35
created

Currency::rules()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 46
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 30
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 46
ccs 30
cts 30
cp 1
rs 8.9411
cc 1
eloc 22
nc 1
nop 0
crap 1
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
    public $id;
12
    public $rate;
13
    public $plus;
14
15
    /**
16
     * @inheritdoc
17
     */
18
    public static function getTagProperties()
19
    {
20
        return [
21
            'id',
22
            'rate',
23
            'plus',
24
        ];
25
    }
26
27 9
    /**
28
     * @inheritdoc
29
     */
30
    public function rules()
31
    {
32 6
        return [
33 6
            [
34 6
                [
35 6
                    'id',
36 9
                    'rate',
37
                ],
38
                'required',
39 6
            ],
40 6
            [
41 6
                [
42 6
                    'rate',
43 6
                ],
44
                'string',
45
                'max' => 5,
46 6
            ],
47 6
            [
48 6
                [
49 6
                    'id',
50 6
                ],
51
                'string',
52
                'max' => 3,
53 6
            ],
54 6
            [
55 6
                [
56 6
                    'plus',
57
                ],
58
                'integer',
59 6
            ],
60 6
            [
61 6
                [
62
                    'id',
63 6
                ],
64 6
                'in',
65 6
                'range' => [
66 6
                    'RUR',
67 6
                    'RUB',
68
                    'UAH',
69 6
                    'KZT',
70 6
                    'USD',
71 6
                    'EUR'
72
                ],
73
            ],
74
        ];
75
    }
76
77 9
    /**
78
     * @inheritdoc
79 9
     */
80
    protected function getYmlBody()
81
    {
82
        return null;
83
    }
84
    
85
    /**
86
     * @return string
87
     */
88
    protected function getYmlEndTag()
89
    {
90
        return '';
91
    }
92
93
    /**
94
     * @return string
95
     */
96 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...
97
    {
98
        $string = '';
99
        if (static::$tag) {
100
            $string = '<' . static::$tag . $this->getYmlTagProperties() . ' />';
101
        }
102
103
        return $string;
104
    }
105
}
106