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

HubCombo   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 19
dl 0
loc 46
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getHubType() 0 3 1
A getFilter() 0 10 2
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