| 1 | <?php |
||
| 7 | class Router |
||
| 8 | { |
||
|
|
|||
| 9 | |||
| 10 | /** |
||
| 11 | * Placeholder for the dispatcher class. |
||
| 12 | * |
||
| 13 | * @var object |
||
| 14 | */ |
||
| 15 | private $dispatcher; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Main controller namespace. |
||
| 19 | * |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | private $namespace = 'Vertex\\Controller\\'; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Create a new router. |
||
| 26 | * |
||
| 27 | * @var \FastRoute\simpleDispatcher |
||
| 28 | * @return void |
||
|
1 ignored issue
–
show
|
|||
| 29 | */ |
||
| 30 | public function __construct($dispatcher) |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Dispatch the route. |
||
| 37 | * |
||
| 38 | * @return void |
||
| 39 | */ |
||
| 40 | public function dispatch() |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Returns the current route information. |
||
| 59 | * |
||
| 60 | * @return array |
||
| 61 | */ |
||
| 62 | public function info() |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Check if a route was found. |
||
| 69 | * |
||
| 70 | * @param string $handler |
||
| 71 | * @param array $parameters |
||
| 72 | */ |
||
| 73 | private function found($handler, $parameters) |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Handle the callback. |
||
| 88 | * |
||
| 89 | * @param string $callback |
||
| 90 | * @param array $parameters |
||
| 91 | */ |
||
| 92 | public function handle($callback, ...$parameters) |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Error responce. |
||
| 101 | * |
||
| 102 | * @param string $type |
||
| 103 | * @param string $description |
||
| 104 | */ |
||
| 105 | private function error($type, $description) |
||
| 113 | } |
||
| 114 |