26 lines
652 B
PHP
26 lines
652 B
PHP
<?php
|
|
|
|
namespace App\Framework\Router;
|
|
|
|
final class RouteCollection
|
|
{
|
|
/** @var array<string, array{static: array<string, callable>, dynamic: array<array{regex: string, handler: callable}>}> */
|
|
private array $routes;
|
|
|
|
public function __construct(array $routes) {
|
|
$this->routes = $routes;
|
|
}
|
|
|
|
public function getStatic(string $method): array {
|
|
return $this->routes[$method]['static'] ?? [];
|
|
}
|
|
|
|
public function getDynamic(string $method): array {
|
|
return $this->routes[$method]['dynamic'] ?? [];
|
|
}
|
|
|
|
public function has(string $method): bool {
|
|
return isset($this->routes[$method]);
|
|
}
|
|
}
|