| Conditions | 6 |
| Paths | 6 |
| Total Lines | 18 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 35 | 6 | protected function handleErrors($code, $body) |
|
| 36 | { |
||
| 37 | switch ($code) { |
||
| 38 | 6 | case 401: |
|
| 39 | 1 | throw new AuthenticationException(); |
|
| 40 | 5 | case 403: |
|
| 41 | 1 | throw new ForbiddenException(); |
|
| 42 | 4 | case 404: |
|
| 43 | 1 | throw new NotFoundException(); |
|
| 44 | 3 | case 422: |
|
| 45 | 1 | throw new ValidationException(json_decode($body, true)['errors']); |
|
| 46 | } |
||
| 47 | |||
| 48 | 2 | if ($code >= 500) { |
|
| 49 | 1 | throw new ServerErrorException(); |
|
| 50 | } |
||
| 51 | |||
| 52 | 1 | throw new HttpException('Unknown HTTP exception', $code); |
|
| 53 | } |
||
| 55 |