1 | <?php |
||
10 | class MiddlewareCollection implements MiddlewareInterface |
||
11 | { |
||
12 | /** |
||
13 | * Create a new dispatcher. |
||
14 | * |
||
15 | * @param array $middleware |
||
16 | * |
||
17 | * @return static |
||
18 | */ |
||
19 | 1 | public static function make(array $middleware = []) |
|
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | private $middleware = []; |
||
28 | |||
29 | /** |
||
30 | * @param array $middleware |
||
31 | */ |
||
32 | 6 | public function __construct(array $middleware = []) |
|
36 | |||
37 | /** |
||
38 | * Add a middleware to the end of the stack. |
||
39 | * |
||
40 | * @param MiddlewareInterface $middleware |
||
41 | * |
||
42 | * @return void |
||
43 | */ |
||
44 | 4 | public function append(MiddlewareInterface $middleware) |
|
48 | |||
49 | /** |
||
50 | * Add a middleware to the beginning of the stack. |
||
51 | * |
||
52 | * @param MiddlewareInterface $middleware |
||
53 | * |
||
54 | * @return void |
||
55 | */ |
||
56 | 1 | public function prepend(MiddlewareInterface $middleware) |
|
60 | |||
61 | /** |
||
62 | * Dispatch the middleware stack. |
||
63 | * |
||
64 | * @param ServerRequestInterface $request |
||
65 | * @param callable $default to call when no middleware is available |
||
66 | * |
||
67 | * @return ResponseInterface |
||
68 | */ |
||
69 | 2 | public function dispatch(ServerRequestInterface $request, callable $default) |
|
75 | |||
76 | /** |
||
77 | * @inheritdoc |
||
78 | */ |
||
79 | 1 | public function process(ServerRequestInterface $request, DelegateInterface $nextContainerDelegate) |
|
86 | } |
||
87 |