1 | <?php |
||
21 | class Pipe implements MiddlewareInterface |
||
22 | { |
||
23 | /** |
||
24 | * @var MiddlewareInterface[] |
||
25 | */ |
||
26 | private $middlewares; |
||
27 | |||
28 | /** |
||
29 | * Dispatcher constructor. |
||
30 | * |
||
31 | * @param MiddlewareInterface[] $middlewares |
||
32 | */ |
||
33 | public function __construct(array $middlewares = []) |
||
37 | |||
38 | /** |
||
39 | * {@inheritdoc} |
||
40 | */ |
||
41 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
53 | |||
54 | /** |
||
55 | * Dispatches the middleware and returns the resulting `ResponseInterface`. |
||
56 | * |
||
57 | * @param ServerRequestInterface $request |
||
58 | * |
||
59 | * @throws \LogicException on unexpected result from any middleware on the middlewares |
||
60 | * |
||
61 | * @return ResponseInterface |
||
62 | */ |
||
63 | public function dispatch(ServerRequestInterface $request) |
||
69 | |||
70 | /** |
||
71 | * @param int $index Middleware index |
||
72 | * |
||
73 | * @return RequestHandlerInterface |
||
74 | */ |
||
75 | private function resolve(int $index): RequestHandlerInterface |
||
89 | } |
||
90 |