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 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
50 | |||
51 | /** |
||
52 | * Dispatches the middleware and returns the resulting `ResponseInterface`. |
||
53 | * |
||
54 | * @throws \LogicException on unexpected result from any middleware on the middlewares |
||
55 | * |
||
56 | * @return ResponseInterface |
||
57 | */ |
||
58 | public function dispatch(ServerRequestInterface $request) |
||
64 | |||
65 | /** |
||
66 | * @param int $index Middleware index |
||
67 | */ |
||
68 | private function resolve(int $index): RequestHandlerInterface |
||
82 | } |
||
83 |