| 1 | <?php |
||
| 9 | abstract class Router implements RouterInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var array $routes An array of routes. |
||
| 13 | */ |
||
| 14 | protected $routes; |
||
| 15 | |||
| 16 | |||
| 17 | /** |
||
| 18 | * @var string $cachePath A file path to cache routes in. |
||
| 19 | */ |
||
| 20 | protected $cachePath; |
||
| 21 | |||
| 22 | |||
| 23 | /** |
||
| 24 | * @param array $routes An array of routes. |
||
| 25 | * @param string $cachePath A file path to cache routes in. |
||
| 26 | */ |
||
| 27 | public function __construct(array $routes, $cachePath = null) |
||
| 32 | |||
| 33 | |||
| 34 | /** |
||
| 35 | * @param RouteInterface $route A route. |
||
| 36 | */ |
||
| 37 | public function addRoute(RouteInterface $route) |
||
| 41 | |||
| 42 | |||
| 43 | /** |
||
| 44 | * @param array $routes An array of routes. |
||
| 45 | */ |
||
| 46 | public function addRoutes(array $routes) |
||
| 52 | |||
| 53 | |||
| 54 | /** |
||
| 55 | * @return array An array of routes. |
||
| 56 | */ |
||
| 57 | public function getRoutes() |
||
| 61 | |||
| 62 | |||
| 63 | /** |
||
| 64 | * Route a request. |
||
| 65 | * |
||
| 66 | * @param RequestInterface $request A request. |
||
| 67 | * @return ResolvedRequestInterface A resolved request. |
||
| 68 | */ |
||
| 69 | abstract public function route(RequestInterface $request); |
||
| 70 | } |
||
| 71 |