Route
Route
Properties
router
public Router $router
callable
private mixed $callable
path
public string $path
responseType
private int $responseType = 'Response'
methods
private array $methods
actionArgs
private array $actionArgs
callableParameters
private array $callableParameters
Methods
__construct
public __construct(?string $path, array $methods): void
Parameters
Parameter | Type | Description |
---|---|---|
$path | string | |
$methods | array |
setCallable
Sets the callable for the route and processes its reflection.
public setCallable(mixed $callable): void
Parameters
Parameter | Type | Description |
---|---|---|
$callable | mixed | The callable to be set. It can be a closure, an array with a class and method, or a reflection method. |
setRouter
Sets the router instance for the application.
public setRouter(Router $router): void
Parameters
Parameter | Type | Description |
---|---|---|
$router | Router | the router instance to be set |
getPath
Retrieves the path associated with the current route.
public getPath(): ?string
Matches the given HTTP method and path against the route's method and path.
public (string $method, string $path): bool
Parameters
Parameter | Type | Description |
---|---|---|
$method | string | The HTTP method to match (e.g., 'GET', 'POST'). |
$path | string | the request path to match |
getControllerClass
public getControllerClass(): string
getControllerName
public getControllerName(): string
getController
Retrieves the controller instance based on the callable property.
public getController(): ?Controller
This method checks if the callable property is a Closure or an array. If it is a Closure, it returns a new Closure instance. If it is an array, it extracts the controller class name, verifies its existence, and returns a new instance of the controller class.
getAction
Retrieves the action to be executed.
public getAction(): string
This method checks if the action is defined in the callable array. If it is, it returns that action. Otherwise, it falls back to the default action specified in the router configuration.
getActionArgs
Retrieve the action arguments.
public getActionArgs(): void
This method returns an array of arguments that are passed to the action.
getResponseType
Retrieves the response type of the route.
public getResponseType(): int
prefixPath
Prefixes the path of the route with the given path.
public prefixPath(string $path): void
Parameters
Parameter | Type | Description |
---|---|---|
$path | string | the path to be prefixed |
Generated by Hazaar API Doc Generator