URIPattern
in package
The URIPattern class is a wrapper to gather several patterns and test them simultaneously.
Table of Contents
- $expression : string
- The patterns used by this class to test the URL it receives.
- $open : bool
- Indicates whether this is an open ended pattern. This implies that it'll accept URL that are longer than the patterns it can test with (these additional parameters will get appended to the object).
- $pattern : mixed
- The pattern is the string that we were given to extract data from the URL. This is mostly used for debugging and information purposes, letting the developer know which rule we're working on.
- $variables : Collection<string|int, array<string|int, string>>
- These are the variables that the user defined in their URL pattern. These are matched and returned to the route.
- __construct() : mixed
- Instances a new URI Pattern. This class allows your application to test whether a URL matches the pattern you gave to the constructor.
- make() : mixed
- reverse() : string
- Takes a parameter list and constructs a string URI from the combination of patterns and parameters.
- test() : Parameters
- Tests whether a given $uri matches the patterns that this object holds.
Properties
$expression
The patterns used by this class to test the URL it receives.
private
string
$expression
$open
Indicates whether this is an open ended pattern. This implies that it'll accept URL that are longer than the patterns it can test with (these additional parameters will get appended to the object).
private
bool
$open
$pattern
The pattern is the string that we were given to extract data from the URL. This is mostly used for debugging and information purposes, letting the developer know which rule we're working on.
private
mixed
$pattern
$variables
These are the variables that the user defined in their URL pattern. These are matched and returned to the route.
private
Collection<string|int, array<string|int, string>>
$variables
Methods
__construct()
Instances a new URI Pattern. This class allows your application to test whether a URL matches the pattern you gave to the constructor.
public
__construct(string $pattern) : mixed
Parameters
- $pattern : string
Return values
mixed —make()
public
static make(mixed $str) : mixed
Parameters
- $str : mixed
Return values
mixed —reverse()
Takes a parameter list and constructs a string URI from the combination of patterns and parameters.
public
reverse(type $parameters) : string
Parameters
- $parameters : type
Tags
Return values
string —test()
Tests whether a given $uri matches the patterns that this object holds.
public
test(string $uri) : Parameters
Please note that if the URI is too long and the pattern is not open ended it will throw a missmatch exception.
Parameters
- $uri : string