commit | author | age | ||
c958d0 | 1 | <?php |
F | 2 | |
3 | class Router { | |
4 | private array $routes = []; | |
5 | ||
6 | public function add(string $path, array $params = []): void { | |
7 | $this->routes[] = [ | |
8 | "path"=> $path, | |
9 | "params"=> $params | |
10 | ]; | |
11 | ||
931be5 | 12 | |
F | 13 | } |
14 | public function match (string $path,): array|bool { | |
15 | foreach ($this->routes as $route) { | |
16 | if ($route["path"] === $path) { | |
17 | return $route["params"]; | |
18 | } | |
19 | } | |
20 | return false; | |
c958d0 | 21 | } |
F | 22 | } |