MultipleBillTypeCombo   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 51
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 9 1
A getData() 0 12 3
1
<?php
2
3
4
namespace hipanel\modules\finance\widgets\combo;
5
6
7
use hiqdev\combo\StaticCombo;
8
9
/**
10
 * Class MultipleBillTypeCombo
11
 * @package hipanel\modules\finance\widgets\combo
12
 */
13
class MultipleBillTypeCombo extends StaticCombo
14
{
15
    /**
16
     * @var array
17
     */
18
    public $billTypes;
19
20
    /**
21
     * @var array
22
     */
23
    public $billGroupLabels;
24
25
    /**
26
     * @inheritDoc
27
     */
28
    public $hasId = true;
29
30
    /**
31
     * @inheritDoc
32
     */
33
    public $multiple = true;
34
35
    /**
36
     * @inheritDoc
37
     */
38
    public function init()
39
    {
40
        parent::init();
41
42
        $this->data = $this->getData();
43
        $this->inputOptions[] = [
44
            'groups' => $this->billGroupLabels,
45
        ];
46
    }
47
48
    /**
49
     * @return array
50
     */
51
    private function getData(): array
52
    {
53
        $types = [];
54
        foreach ($this->billTypes as $gtype => $category) {
55
            $item = [];
56
            foreach ($category as $key => $label) {
57
                $item[substr($key, strpos($key, ',') + 1)] = $label;
58
            }
59
            $types[$gtype] = $item;
60
        }
61
        return $types;
62
    }
63
}
64