Completed
Push — master ( f04bdf...03085f )
by Andrii
05:00
created

Config::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 26
ccs 0
cts 25
cp 0
rs 9.6333
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Server module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-server
6
 * @package   hipanel-module-server
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
namespace hipanel\modules\server\models;
11
12
use hipanel\base\Model;
13
use hipanel\base\ModelTrait;
14
use Yii;
15
16
class Config extends Model
17
{
18
    use ModelTrait;
19
20
    const SCENARIO_CREATE = 'create';
21
    const SCENARIO_UPDATE = 'update';
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function rules()
27
    {
28
        return array_merge(parent::rules(), [
29
            [['id', 'client_id', 'type_id', 'state_id'], 'integer'],
30
            [['name', 'client', 'state', 'state_label', 'type', 'type_label'], 'string'],
31
            [['sort_order'], 'integer', 'min'=>0],
32
            [
33
                [
34
                    'data',
35
                    'name',
36
                    'label',
37
                    'cpu',
38
                    'ram',
39
                    'hdd',
40
                    'ssd',
41
                    'traffic',
42
                    'lan',
43
                    'raid',
44
                    'descr',
45
                ], 'string'],
46
            [
47
                ['client_id', 'name', 'label', 'cpu', 'ram'],
48
                'required', 'on' => ['create', 'update'],
49
            ],
50
51
            ['id', 'required', 'on' => 'delete']
52
        ]);
53
    }
54
55
    public function attributeLabels()
56
    {
57
        return array_merge(parent::attributeLabels(), [
58
            'label'      => 'Subname',
59
            'cpu'        => 'CPU',
60
            'ram'        => 'RAM',
61
            'hdd'        => 'HDD',
62
            'ssd'        => 'SSD',
63
            'lan'        => 'LAN',
64
            'raid'       => 'RAID',
65
            'sort_order' => 'Sort order',
66
        ]);
67
    }
68
}
69