| 1 | <?php |
||
| 8 | class Runner |
||
| 9 | { |
||
| 10 | |||
| 11 | /* @var runner */ |
||
| 12 | protected $next; |
||
| 13 | |||
| 14 | protected $middleware; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Creates a runner based on an array of middleware |
||
| 18 | * |
||
| 19 | * @param array $middlewares |
||
| 20 | * @return Runner |
||
| 21 | */ |
||
| 22 | 1 | public static function factory(array $middlewares = array()) |
|
| 30 | |||
| 31 | 4 | public function __construct(callable $middleware = null) |
|
| 35 | |||
| 36 | /** |
||
| 37 | * Returns a new instance of a runner (ie: immutable middleware runner) |
||
| 38 | * |
||
| 39 | * @param callable $middleware |
||
| 40 | * @return Runner |
||
| 41 | */ |
||
| 42 | 3 | public function add(callable $middleware) |
|
| 49 | |||
| 50 | /** |
||
| 51 | * @param ServerRequestInterface $request |
||
| 52 | * @param ResponseInterface $response |
||
| 53 | * @return ResponseInterface |
||
| 54 | */ |
||
| 55 | 4 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response) |
|
| 68 | } |
||
| 69 |