| Total Complexity | 2 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 13 | class ClientMiddleware |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * Return a callback that can be used as double pass middleware. |
||
| 17 | * |
||
| 18 | * @return callable |
||
| 19 | */ |
||
| 20 | 1 | public function asDoublePass(): callable |
|
| 21 | { |
||
| 22 | return function (RequestInterface $request, ResponseInterface $response, callable $next): ResponseInterface { |
||
| 23 | 1 | return $next($request, $response); |
|
| 24 | 1 | }; |
|
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Return a callback that can be used as Guzzle middleware. |
||
| 29 | * @see http://docs.guzzlephp.org/en/stable/handlers-and-middleware.html |
||
| 30 | * |
||
| 31 | * @return callable |
||
| 32 | */ |
||
| 33 | 2 | public function forGuzzle(): callable |
|
| 34 | { |
||
| 35 | return function (callable $handler) { |
||
| 36 | return function (RequestInterface $request, array $options) use ($handler) { |
||
| 37 | 2 | return $handler($request, $options); |
|
| 38 | 2 | }; |
|
| 39 | 2 | }; |
|
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Create a version of this middleware that can be used in HTTPlug. |
||
| 44 | * @see http://docs.php-http.org/en/latest/plugins/introduction.html |
||
| 45 | * |
||
| 46 | * @return self&HttpPlugin |
||
|
|
|||
| 47 | */ |
||
| 48 | public function forHttplug(): HttpPlugin |
||
| 49 | { |
||
| 50 | return new class () extends ClientMiddleware implements HttpPlugin { |
||
| 51 | 1 | public function handleRequest(RequestInterface $request, callable $next, callable $first): HttpPromise |
|
| 54 | } |
||
| 55 | }; |
||
| 56 | } |
||
| 57 | } |
||
| 58 |