StatusTrait   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 18.18%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 11
c 1
b 0
f 0
dl 0
loc 24
ccs 2
cts 11
cp 0.1818
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getStatusName() 0 12 3
A isDisabled() 0 3 1
A isActive() 0 3 1
1
<?php
2
namespace App\Model;
3
4
trait StatusTrait
5
{
6 1
    public function isActive(): bool
7
    {
8 1
        return $this->status === StatusInterface::STATUS_ACTIVE;
9
    }
10
11
    public function isDisabled(): bool
12
    {
13
        return $this->status === StatusInterface::STATUS_DISABLED;
0 ignored issues
show
Bug introduced by
The constant App\Model\StatusInterface::STATUS_DISABLED was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
14
    }
15
16
    public function getStatusName(): string
17
    {
18
        switch ($this->status) {
19
            case StatusInterface::STATUS_ACTIVE:
20
                return \Yii::t('app', 'Active');
21
            case StatusInterface::STATUS_DISABLED:
0 ignored issues
show
Bug introduced by
The constant App\Model\StatusInterface::STATUS_DISABLED was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
22
                return \Yii::t('app', 'Disable');
23
            default:
24
                return \Yii::t('app', 'Unknown');
25
        }
26
27
        return 'Unknown';
0 ignored issues
show
Unused Code introduced by
return 'Unknown' is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
28
    }
29
}
30