| 1 | <?php |
||
| 9 | class Stack |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var array |
||
| 13 | */ |
||
| 14 | private $middleware; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @param array $middleware |
||
| 18 | */ |
||
| 19 | 3 | public function __construct(array $middleware = []) |
|
| 23 | |||
| 24 | /** |
||
| 25 | * Add a middleware to the end of the stack. |
||
| 26 | * |
||
| 27 | * @param ServerMiddlewareInterface $middleware |
||
| 28 | * |
||
| 29 | * @return void |
||
| 30 | */ |
||
| 31 | 1 | public function append(ServerMiddlewareInterface $middleware) |
|
| 35 | |||
| 36 | /** |
||
| 37 | * Add a middleware to the beginning of the stack. |
||
| 38 | * |
||
| 39 | * @param ServerMiddlewareInterface $middleware |
||
| 40 | * |
||
| 41 | * @return void |
||
| 42 | */ |
||
| 43 | 1 | public function prepend(ServerMiddlewareInterface $middleware) |
|
| 47 | |||
| 48 | /** |
||
| 49 | * Dispatch the middleware stack. |
||
| 50 | * |
||
| 51 | * @param ServerRequestInterface $request |
||
| 52 | * @param callable $default to call when no middleware is available |
||
| 53 | * |
||
| 54 | * @return ResponseInterface |
||
| 55 | */ |
||
| 56 | 2 | public function dispatch(ServerRequestInterface $request, callable $default) |
|
| 62 | } |
||
| 63 |