| Conditions | 2 |
| Paths | 1 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | 5 | public function __invoke(callable $handler) |
|
| 33 | { |
||
| 34 | return function (RequestInterface $request, array $options) use ($handler) { |
||
| 35 | // Set starting time. |
||
| 36 | 4 | $start = microtime(true); |
|
| 37 | |||
| 38 | 4 | return $handler($request, $options) |
|
| 39 | ->then(function (ResponseInterface $response) use ($start, $request) { |
||
| 40 | // After |
||
| 41 | 1 | $this->profiler->add($start, microtime(true), $request, $response); |
|
| 42 | |||
| 43 | 1 | return $response; |
|
| 44 | }, function (GuzzleException $exception) use ($start, $request) { |
||
| 45 | 2 | $response = $exception instanceof RequestException ? $exception->getResponse() : null; |
|
| 46 | 2 | $this->profiler->add($start, microtime(true), $request, $response); |
|
| 47 | |||
| 48 | 2 | throw $exception; |
|
| 49 | 4 | }); |
|
| 50 | 5 | }; |
|
| 51 | } |
||
| 52 | } |
||
| 53 |