Completed
Push — master ( 871cd8...ab1e03 )
by Kirill
03:44
created

Shop::rules()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 1.026

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 27
ccs 19
cts 27
cp 0.7037
rs 8.8571
cc 1
eloc 14
nc 1
nop 0
crap 1.026
1
<?php
2
namespace pastuhov\ymlcatalog\models;
3
4
class Shop extends BaseModel
5
{
6
    /**
7
     * @inheritdoc
8
     */
9
    public static $tag = false;
10
11
    public $name;
12
    public $company;
13
    public $url;
14
    public $platform;
15
    public $version;
16
    public $agency;
17
    public $email;
18
    public $cpa;
19
20
    /**
21
     * @inheritdoc
22
     */
23 5
    public function rules()
24
    {
25
        return [
26
            [
27 5
                ['name', 'company', 'url'],
28 5
                'required',
29 5
            ],
30
            [
31 5
                ['name'],
32 5
                'string',
33 5
                'max' => 20,
34 5
            ],
35
            [
36 5
                ['company', 'url', 'platform', 'version', 'agency', 'email'],
37 5
                'string',
38 5
                'max' => 255,
39 5
            ],
40
            [
41 5
                ['email'],
42 5
                'email',
43 5
            ],
44
            [
45 5
                ['cpa'],
46 5
                'boolean',
47 5
            ],
48 5
        ];
49
    }
50
51
    /**
52
     * @inheritdoc
53
     */
54 5
    protected function getYmlBody()
55
    {
56 5
        $string = '';
57
58 5
        foreach ($this->getYmlAttributes() as $attribute) {
59 5
            $string .= $this->getYmlAttribute($attribute);
60 5
        }
61
62 5
        return $string;
63
    }
64
}
65