| 1 | <?php |
||
| 9 | class Handler implements RequestHandlerInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var array |
||
| 13 | */ |
||
| 14 | private $middleware; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var callable |
||
| 18 | */ |
||
| 19 | private $default; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var integer |
||
| 23 | */ |
||
| 24 | private $index = 0; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @param array $middleware |
||
| 28 | * @param callable $default |
||
| 29 | */ |
||
| 30 | 4 | public function __construct(array $middleware, callable $default) |
|
| 35 | |||
| 36 | /** |
||
| 37 | * Process the request using the current middleware. |
||
| 38 | * |
||
| 39 | * @param ServerRequestInterface $request |
||
| 40 | * |
||
| 41 | * @return ResponseInterface |
||
| 42 | */ |
||
| 43 | 4 | public function handle(ServerRequestInterface $request) |
|
| 51 | |||
| 52 | /** |
||
| 53 | * Get a handler pointing to the next middleware. |
||
| 54 | * |
||
| 55 | * @return static |
||
| 56 | */ |
||
| 57 | 2 | private function nextHandler() |
|
| 64 | } |
||
| 65 |