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