Conditions | 1 |
Paths | 1 |
Total Lines | 25 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
21 | public function __invoke(callable $handler) |
||
22 | { |
||
23 | |||
24 | return function ($request, array $options = []) use ($handler) { |
||
25 | |||
26 | return $handler($request, $options)->then( |
||
27 | function ($value) use ($request, $options) { |
||
28 | |||
29 | $transaction = (new Transaction) |
||
30 | ->setRequest(AssertableRequest::fromBaseRequest($request)) |
||
31 | ->setResponse(AssertableResponse::fromBaseResponse($value)) |
||
32 | ->setOptions($options); |
||
33 | $this->container->push($transaction); |
||
34 | |||
35 | return $value; |
||
36 | }, |
||
37 | function ($reason) use ($request, $options) { |
||
38 | |||
39 | $transaction = (new Transaction) |
||
40 | ->setRequest(AssertableRequest::fromBaseRequest($request)) |
||
41 | ->setError($reason) |
||
42 | ->setOptions($options); |
||
43 | $this->container->push($transaction); |
||
44 | |||
45 | return \GuzzleHttp\Promise\rejection_for($reason); |
||
46 | } |
||
51 |