| Total Complexity | 3 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 14 | class Delegate implements RequestHandlerInterface |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var callable |
||
| 18 | */ |
||
| 19 | private $callback; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param callable $callback function (RequestInterface $request) : ResponseInterface |
||
| 23 | */ |
||
| 24 | 1 | public function __construct(callable $callback) |
|
| 25 | { |
||
| 26 | 1 | $this->callback = $callback; |
|
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Dispatch the next available middleware and return the response. |
||
| 31 | * |
||
| 32 | * @param ServerRequestInterface $request |
||
| 33 | * |
||
| 34 | * @return ResponseInterface |
||
| 35 | */ |
||
| 36 | 1 | public function handle(ServerRequestInterface $request): ResponseInterface |
|
| 37 | { |
||
| 38 | 1 | return ($this->callback)($request); |
|
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Dispatch the next available middleware and return the response. |
||
| 43 | * |
||
| 44 | * This method duplicates `handle()` to provide support for `callable` middleware. |
||
| 45 | * |
||
| 46 | * @param ServerRequestInterface $request |
||
| 47 | * |
||
| 48 | * @return ResponseInterface |
||
| 49 | */ |
||
| 50 | 1 | public function __invoke(ServerRequestInterface $request) |
|
| 53 | } |
||
| 54 | } |
||
| 55 |