Completed
Push — master ( 40a649...4fd464 )
by Dmitry
12:14
created

BillType   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 32
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getModelLabel() 0 6 1
1
<?php
2
3
namespace hipanel\modules\finance\widgets;
4
5
use hipanel\models\Ref;
6
use hipanel\widgets\Type;
7
8
class BillType extends Type
9
{
10
    public $defaultValues = [
11
        'success' => [
12
            'deposit,*',
13
            'monthly,*',
14
        ],
15
        'info' => [
16
            'overuse,*',
17
        ],
18
        'warning' => [
19
            'monthly,monthly',
20
            'exchange,*'
21
        ],
22
        'primary' => [
23
            'monthly,leasing',
24
        ],
25
        'default' => [
26
            'monthly,hardware',
27
            'correction,*',
28
        ],
29
    ];
30
    public $field = 'type';
31
    public $i18nDictionary = 'hipanel.finance.billTypes';
32
33
    protected function getModelLabel(): string
34
    {
35
        $billTypes = Ref::getListRecursively('type,bill', false);
0 ignored issues
show
Bug introduced by
The method getListRecursively() does not exist on hipanel\models\Ref. Did you maybe mean getList()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
36
37
        return $billTypes[$this->getFieldValue()] ?? $this->getFieldValue();
0 ignored issues
show
Documentation Bug introduced by
The method getFieldValue does not exist on object<hipanel\modules\finance\widgets\BillType>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
38
    }
39
}
40
41
42