MonitoringForm   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 52
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 5 1
A attributeHints() 0 11 1
A attributeLabels() 0 13 1
A scenarios() 0 9 1
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 $categories;
19
20
    public function rules()
21
    {
22
        return [
23
            ['names', 'required'],
24
            [['names', 'categories'], 'safe'],
25
        ];
26
    }
27
28
    public function scenarios()
29
    {
30
        return [
31
            TrackerType::ACCOUNT => [
32
                'names',
33
                'categories'
34
            ],
35
            TrackerType::TAG => [
36
                'names',
37
            ],
38
        ];
39
    }
40
41
    public function attributeLabels()
42
    {
43
        $labels = parent::attributeLabels();
44
        $trackerTypeLabels = [
45
            TrackerType::ACCOUNT => [
46
                'names' => 'Accounts',
47
            ],
48
            TrackerType::TAG => [
49
                'names' => 'Tags',
50
            ],
51
        ];
52
53
        return ArrayHelper::merge($labels, ArrayHelper::getValue($trackerTypeLabels, $this->scenario, []));
54
    }
55
56
    public function attributeHints()
57
    {
58
        $hints = [
59
            'names' => 'Comma separated list.',
60
        ];
61
        $trackerTypeHints = [
62
            TrackerType::ACCOUNT => [],
63
            TrackerType::TAG => [],
64
        ];
65
66
        return ArrayHelper::merge($hints, ArrayHelper::getValue($trackerTypeHints, $this->scenario, []));
67
    }
68
}