Route
in package
implements
Serializable
A Route describes a route and its parameters.
Tags
Table of Contents
Interfaces
- Serializable
Properties
- $compiled : mixed
- $condition : string
- $defaults : array<string|int, mixed>
- $host : string
- $methods : array<string|int, mixed>
- $options : array<string|int, mixed>
- $path : string
- $requirements : array<string|int, mixed>
- $schemes : array<string|int, mixed>
Methods
- __construct() : mixed
- Constructor.
- __serialize() : array<string|int, mixed>
- __unserialize() : void
- addDefaults() : $this
- addOptions() : $this
- addRequirements() : $this
- compile() : CompiledRoute
- Compiles the route.
- getCondition() : string
- getDefault() : mixed
- getDefaults() : array<string|int, mixed>
- getHost() : string
- getMethods() : array<string|int, string>
- Returns the uppercased HTTP methods this route is restricted to.
- getOption() : mixed
- Returns the option value or null when not found.
- getOptions() : array<string|int, mixed>
- getPath() : string
- getRequirement() : string|null
- getRequirements() : array<string|int, mixed>
- getSchemes() : array<string|int, string>
- Returns the lowercased schemes this route is restricted to.
- hasDefault() : bool
- hasOption() : bool
- hasRequirement() : bool
- hasScheme() : bool
- Checks if a scheme requirement has been set.
- setCondition() : $this
- setDefault() : $this
- setDefaults() : $this
- setHost() : $this
- setMethods() : $this
- Sets the HTTP methods (e.g. 'POST') this route is restricted to.
- setOption() : $this
- Sets an option value.
- setOptions() : $this
- setPath() : $this
- setRequirement() : $this
- setRequirements() : $this
- setSchemes() : $this
- Sets the schemes (e.g. 'https') this route is restricted to.
- extractInlineDefaultsAndRequirements() : string
- isLocalized() : bool
- sanitizeRequirement() : mixed
Properties
$compiled
private
mixed
$compiled
= null
$condition
private
string
$condition
= ''
$defaults
private
array<string|int, mixed>
$defaults
= []
$host
private
string
$host
= ''
$methods
private
array<string|int, mixed>
$methods
= []
$options
private
array<string|int, mixed>
$options
= []
$path
private
string
$path
= '/'
$requirements
private
array<string|int, mixed>
$requirements
= []
$schemes
private
array<string|int, mixed>
$schemes
= []
Methods
__construct()
Constructor.
public
__construct(string $path[, array<string|int, mixed> $defaults = [] ][, array<string|int, mixed> $requirements = [] ][, array<string|int, mixed> $options = [] ][, string|null $host = '' ][, string|array<string|int, string> $schemes = [] ][, string|array<string|int, string> $methods = [] ][, string|null $condition = '' ]) : mixed
Available options:
- compiler_class: A class name able to compile this route instance (RouteCompiler by default)
- utf8: Whether UTF-8 matching is enforced ot not
Parameters
- $path : string
-
The path pattern to match
- $defaults : array<string|int, mixed> = []
-
An array of default parameter values
- $requirements : array<string|int, mixed> = []
-
An array of requirements for parameters (regexes)
- $options : array<string|int, mixed> = []
-
An array of options
- $host : string|null = ''
-
The host pattern to match
- $schemes : string|array<string|int, string> = []
-
A required URI scheme or an array of restricted schemes
- $methods : string|array<string|int, string> = []
-
A required HTTP method or an array of restricted methods
- $condition : string|null = ''
-
A condition that should evaluate to true for the route to match
__serialize()
public
__serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>__unserialize()
public
__unserialize(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
addDefaults()
public
addDefaults(array<string|int, mixed> $defaults) : $this
Parameters
- $defaults : array<string|int, mixed>
Return values
$thisaddOptions()
public
addOptions(array<string|int, mixed> $options) : $this
Parameters
- $options : array<string|int, mixed>
Return values
$thisaddRequirements()
public
addRequirements(array<string|int, mixed> $requirements) : $this
Parameters
- $requirements : array<string|int, mixed>
Return values
$thiscompile()
Compiles the route.
public
compile() : CompiledRoute
Tags
Return values
CompiledRoutegetCondition()
public
getCondition() : string
Return values
stringgetDefault()
public
getDefault(string $name) : mixed
Parameters
- $name : string
getDefaults()
public
getDefaults() : array<string|int, mixed>
Return values
array<string|int, mixed>getHost()
public
getHost() : string
Return values
stringgetMethods()
Returns the uppercased HTTP methods this route is restricted to.
public
getMethods() : array<string|int, string>
So an empty array means that any method is allowed.
Return values
array<string|int, string>getOption()
Returns the option value or null when not found.
public
getOption(string $name) : mixed
Parameters
- $name : string
getOptions()
public
getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>getPath()
public
getPath() : string
Return values
stringgetRequirement()
public
getRequirement(string $key) : string|null
Parameters
- $key : string
Return values
string|nullgetRequirements()
public
getRequirements() : array<string|int, mixed>
Return values
array<string|int, mixed>getSchemes()
Returns the lowercased schemes this route is restricted to.
public
getSchemes() : array<string|int, string>
So an empty array means that any scheme is allowed.
Return values
array<string|int, string>hasDefault()
public
hasDefault(string $name) : bool
Parameters
- $name : string
Return values
boolhasOption()
public
hasOption(string $name) : bool
Parameters
- $name : string
Return values
boolhasRequirement()
public
hasRequirement(string $key) : bool
Parameters
- $key : string
Return values
boolhasScheme()
Checks if a scheme requirement has been set.
public
hasScheme(string $scheme) : bool
Parameters
- $scheme : string
Return values
boolsetCondition()
public
setCondition(string|null $condition) : $this
Parameters
- $condition : string|null
Return values
$thissetDefault()
public
setDefault(string $name, mixed $default) : $this
Parameters
- $name : string
- $default : mixed
Return values
$thissetDefaults()
public
setDefaults(array<string|int, mixed> $defaults) : $this
Parameters
- $defaults : array<string|int, mixed>
Return values
$thissetHost()
public
setHost(string|null $pattern) : $this
Parameters
- $pattern : string|null
Return values
$thissetMethods()
Sets the HTTP methods (e.g. 'POST') this route is restricted to.
public
setMethods(string|array<string|int, string> $methods) : $this
So an empty array means that any method is allowed.
Parameters
- $methods : string|array<string|int, string>
-
The method or an array of methods
Return values
$thissetOption()
Sets an option value.
public
setOption(string $name, mixed $value) : $this
Parameters
- $name : string
- $value : mixed
Return values
$thissetOptions()
public
setOptions(array<string|int, mixed> $options) : $this
Parameters
- $options : array<string|int, mixed>
Return values
$thissetPath()
public
setPath(string $pattern) : $this
Parameters
- $pattern : string
Return values
$thissetRequirement()
public
setRequirement(string $key, string $regex) : $this
Parameters
- $key : string
- $regex : string
Return values
$thissetRequirements()
public
setRequirements(array<string|int, mixed> $requirements) : $this
Parameters
- $requirements : array<string|int, mixed>
Return values
$thissetSchemes()
Sets the schemes (e.g. 'https') this route is restricted to.
public
setSchemes(string|array<string|int, string> $schemes) : $this
So an empty array means that any scheme is allowed.
Parameters
- $schemes : string|array<string|int, string>
-
The scheme or an array of schemes
Return values
$thisextractInlineDefaultsAndRequirements()
private
extractInlineDefaultsAndRequirements(string $pattern) : string
Parameters
- $pattern : string
Return values
stringisLocalized()
private
isLocalized() : bool
Return values
boolsanitizeRequirement()
private
sanitizeRequirement(string $key, string $regex) : mixed
Parameters
- $key : string
- $regex : string