Passed
Push — master ( d23c33...74888d )
by Andrii
03:48
created

HubCombo::getFilter()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 10
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
1
<?php
2
3
namespace hipanel\modules\server\widgets\combo;
4
5
use hiqdev\combo\Combo;
6
use yii\helpers\ArrayHelper;
7
8
class HubCombo extends Combo
9
{
10
    const IPMI = 'net';
11
    const KVM = 'kvm';
12
    const NET = 'net';
13
    const PDU = 'pdu';
14
    const RACK = 'rack';
15
16
    /** {@inheritdoc} */
17
    public $name = 'name';
18
19
    /** {@inheritdoc} */
20
    public $type = 'server/hub';
21
22
    /** {@inheritdoc} */
23
    public $url = '/server/hub/index';
24
25
    /** {@inheritdoc} */
26
    public $_return = ['id'];
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public $primaryFilter = 'name_ilike';
32
33
    /** {@inheritdoc} */
34
    public $_rename = ['text' => 'name'];
35
36
    public $hubType;
37
38
    /** {@inheritdoc} */
39
    public function getFilter()
40
    {
41
        if ($this->hubType) {
42
            return ArrayHelper::merge(parent::getFilter(), [
43
                'type' => ['format' => $this->getHubType()],
44
                'limit' => ['format' => '50'],
45
            ]);
46
        }
47
48
        return parent::getFilter();
49
    }
50
51
    private function getHubType()
52
    {
53
        return $this->hubType;
54
    }
55
}
56
57