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