29 lines
615 B
PHP
29 lines
615 B
PHP
<?php
|
|
|
|
namespace App\Framework\Router;
|
|
|
|
use App\Framework\Http\Method;
|
|
use Closure;
|
|
|
|
final class RouteContext
|
|
{
|
|
public null|Closure $handler {
|
|
get => $this->isSuccess() ? $this->match->route->method : null;
|
|
}
|
|
|
|
public array $params {
|
|
get => $this->isSuccess() ? $this->match->route->parameters : [];
|
|
}
|
|
|
|
public function __construct(
|
|
public readonly RouteMatch $match,
|
|
public readonly Method $method,
|
|
public readonly string $path
|
|
) {}
|
|
|
|
public function isSuccess(): bool
|
|
{
|
|
return $this->match instanceof RouteMatchSuccess;
|
|
}
|
|
}
|