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
![]() |
|||
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
|
|||
22 | return \Yii::t('app', 'Disable'); |
||
23 | default: |
||
24 | return \Yii::t('app', 'Unknown'); |
||
25 | } |
||
26 | |||
27 | return 'Unknown'; |
||
0 ignored issues
–
show
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 function fx() {
try {
doSomething();
return true;
}
catch (\Exception $e) {
return false;
}
return false;
}
In the above example, the last ![]() |
|||
28 | } |
||
29 | } |
||
30 |