chore: lots of changes
This commit is contained in:
27
src/Framework/Router/RouteContext.php
Normal file
27
src/Framework/Router/RouteContext.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Framework\Router;
|
||||
|
||||
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 string $method,
|
||||
public readonly string $path
|
||||
) {}
|
||||
|
||||
public function isSuccess(): bool
|
||||
{
|
||||
return $this->match instanceof RouteMatchSuccess;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user