Passed
Push — master ( eb4b1c...eb14df )
by Paweł
03:02
created

MonitoringForm::attributeHints()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created for IG Monitoring.
4
 * User: jakim <[email protected]>
5
 * Date: 11.03.2018
6
 */
7
8
namespace app\modules\admin\models;
9
10
11
use app\dictionaries\TrackerType;
12
use yii\base\Model;
13
use yii\helpers\ArrayHelper;
14
15
class MonitoringForm extends Model
16
{
17
    public $names;
18
    public $tags;
19
    public $proxy_id;
20
    public $proxy_tag_id;
21
22
    public function rules()
23
    {
24
        return [
25
            ['names', 'required'],
26
            [['names', 'tags', 'proxy_id', 'proxy_tag_id'], 'safe'],
27
        ];
28
    }
29
30
    public function scenarios()
31
    {
32
        return [
33
            TrackerType::ACCOUNT => [
34
                'names',
35
                'tags', 'proxy_id', 'proxy_tag_id',
36
            ],
37
            TrackerType::TAG => [
38
                'names',
39
                'proxy_id', 'proxy_tag_id',
40
            ],
41
        ];
42
    }
43
44
    public function attributeLabels()
45
    {
46
        $labels = parent::attributeLabels();
47
        $trackerTypeLabels = [
48
            TrackerType::ACCOUNT => [
49
                'names' => 'Accounts',
50
            ],
51
            TrackerType::TAG => [
52
                'names' => 'Tags',
53
            ],
54
        ];
55
56
        return ArrayHelper::merge($labels, ArrayHelper::getValue($trackerTypeLabels, $this->scenario, []));
57
    }
58
59
    public function attributeHints()
60
    {
61
        $hints = [
62
            'names' => 'Comma separated list.',
63
        ];
64
        $trackerTypeHints = [
65
            TrackerType::ACCOUNT => [],
66
            TrackerType::TAG => [],
67
        ];
68
69
        return ArrayHelper::merge($hints, ArrayHelper::getValue($trackerTypeHints, $this->scenario, []));
70
    }
71
}