HubCombo   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 19
c 2
b 0
f 0
dl 0
loc 46
ccs 0
cts 13
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getHubType() 0 3 1
A getFilter() 0 10 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
11
namespace hipanel\modules\server\widgets\combo;
12
13
use hiqdev\combo\Combo;
14
use yii\helpers\ArrayHelper;
15
16
class HubCombo extends Combo
17
{
18
    const IPMI = 'net';
19
    const KVM = 'kvm';
20
    const NET = 'net';
21
    const PDU = 'pdu';
22
    const RACK = 'rack';
23
24
    /** {@inheritdoc} */
25
    public $name = 'name';
26
27
    /** {@inheritdoc} */
28
    public $type = 'server/hub';
29
30
    /** {@inheritdoc} */
31
    public $url = '/server/hub/index';
32
33
    /** {@inheritdoc} */
34
    public $_return = ['id'];
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public $primaryFilter = 'name_ilike';
40
41
    /** {@inheritdoc} */
42
    public $_rename = ['text' => 'name'];
43
44
    public $hubType;
45
46
    /** {@inheritdoc} */
47
    public function getFilter()
48
    {
49
        if ($this->hubType) {
50
            return ArrayHelper::merge(parent::getFilter(), [
51
                'type' => ['format' => $this->getHubType()],
52
                'limit' => ['format' => '50'],
53
            ]);
54
        }
55
56
        return parent::getFilter();
57
    }
58
59
    private function getHubType()
60
    {
61
        return $this->hubType;
62
    }
63
}
64