Conditions | 5 |
Paths | 5 |
Total Lines | 21 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
22 | 17 | public function process(RequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
|
23 | { |
||
24 | 17 | $response = $handler->handle($request); |
|
25 | |||
26 | 17 | if ($response->getStatusCode() >= 500) { |
|
27 | 2 | throw new UnavailableException($response->getReasonPhrase()); |
|
28 | } |
||
29 | |||
30 | 15 | if ($response->getStatusCode() === 404) { |
|
31 | 1 | throw new NotFoundException('No results found'); |
|
32 | } |
||
33 | |||
34 | 14 | if ($response->getStatusCode() === 401) { |
|
35 | 1 | throw new AuthorizationException($response->getReasonPhrase()); |
|
36 | } |
||
37 | |||
38 | 13 | if ($response->getStatusCode() >= 400) { |
|
39 | 1 | throw new ResponseException($response->getReasonPhrase()); |
|
40 | } |
||
41 | |||
42 | 12 | return $response; |
|
43 | } |
||
45 |