Conditions | 9 |
Paths | 10 |
Total Lines | 22 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | public static function exception($code, $msg = null) |
||
17 | { |
||
18 | switch ($code) { |
||
19 | case 400: |
||
20 | $msg = $msg ? $msg : Yii::t('app', 'Bad request'); |
||
21 | throw new \yii\web\BadRequestHttpException($msg); |
||
22 | break; |
||
|
|||
23 | case 401: |
||
24 | $msg = $msg ? $msg : Yii::t('app', 'Access is unauthorized'); |
||
25 | throw new \yii\web\UnauthorizedHttpException($msg); |
||
26 | break; |
||
27 | case 403: |
||
28 | $msg = $msg ? $msg : Yii::t('app', 'Access Denied'); |
||
29 | throw new \yii\web\ForbiddenHttpException($msg); |
||
30 | break; |
||
31 | case 404: |
||
32 | default: |
||
33 | $msg = $msg ? $msg : Yii::t('app', 'Page not found'); |
||
34 | throw new \yii\web\NotFoundHttpException($msg); |
||
35 | break; |
||
36 | } |
||
37 | } |
||
38 | } |
||
39 |
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
orexit
statements that have been added for debug purposes.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.