StatusTrait::getStatusName()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 12
ccs 0
cts 7
cp 0
rs 10
cc 3
nc 3
nop 0
crap 12
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