Conditions | 1 |
Paths | 2 |
Total Lines | 26 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 1 |
Changes | 0 |
1 | <?php |
||
50 | 7 | public function handleRequest(RequestInterface $request, callable $next, callable $first) |
|
51 | { |
||
52 | 7 | $stack = new Stack($this->client, $this->formatter->formatRequest($request)); |
|
53 | |||
54 | 7 | $this->collector->addStack($stack); |
|
55 | 7 | $this->collector->activateStack($stack); |
|
56 | |||
57 | $onFulfilled = function (ResponseInterface $response) use ($stack) { |
||
58 | 4 | $stack->setResponse($this->formatter->formatResponse($response)); |
|
59 | |||
60 | 4 | return $response; |
|
61 | 7 | }; |
|
62 | |||
63 | 7 | $onRejected = function (Exception $exception) use ($stack) { |
|
64 | 1 | $stack->setResponse($this->formatter->formatException($exception)); |
|
65 | 1 | $stack->setFailed(true); |
|
66 | |||
67 | 1 | throw $exception; |
|
68 | 7 | }; |
|
69 | |||
70 | try { |
||
71 | 7 | return $next($request)->then($onFulfilled, $onRejected); |
|
72 | } finally { |
||
73 | 7 | $this->collector->deactivateStack($stack); |
|
74 | 7 | } |
|
75 | } |
||
76 | } |
||
77 |