Rule
in package
Router Rule Object
Tags
Table of Contents
- $dynamicSegmentCount : int
- $segments : array<string|int, mixed>
- $staticSegmentCount : int
- $staticUrl : string
- $wildSegmentCount : int
- $afterMatchCallback : function
- $conditionCallback : function
- $ruleName : string
- $rulePattern : string
- __construct() : mixed
- Creates a new router rule instance.
- afterMatch() : callable
- After match callback
- condition() : callable
- Condition callback
- name() : object
- Unique route name
- pattern() : object
- Route match pattern
- resolveUrl() : bool
- Checks whether a given URL matches a given pattern.
- captureWildcardSegments() : array<string|int, mixed>
- Captures and removes every segment of a URL after a wildcard pattern segment is detected, until both collections of segments are the same size.
Properties
$dynamicSegmentCount
public
int
$dynamicSegmentCount
= 0
The number of dynamic segments found in the pattern
$segments
public
array<string|int, mixed>
$segments
Pattern segments
$staticSegmentCount
public
int
$staticSegmentCount
= 0
The number of static segments found in the pattern
$staticUrl
public
string
$staticUrl
URL with static segments only, dynamic segments are stripped
$wildSegmentCount
public
int
$wildSegmentCount
= 0
The number of wildcard segments found in the pattern
$afterMatchCallback
protected
function
$afterMatchCallback
Called when this rule is matched.
$conditionCallback
protected
function
$conditionCallback
Custom condition used when matching this rule.
$ruleName
protected
string
$ruleName
A named reference for this rule.
$rulePattern
protected
string
$rulePattern
The pattern used to match this rule.
Methods
__construct()
Creates a new router rule instance.
public
__construct(string $name, string $pattern) : mixed
Parameters
- $name : string
- $pattern : string
Return values
mixed —afterMatch()
After match callback
public
afterMatch([callable $callback = null ]) : callable
Parameters
- $callback : callable = null
-
Callback function to be used to modify params after a successful match
Tags
Return values
callable —condition()
Condition callback
public
condition([callable $callback = null ]) : callable
Parameters
- $callback : callable = null
-
Callback function to be used when providing custom route match conditions
Tags
Return values
callable —name()
Unique route name
public
name([string $name = null ]) : object
Parameters
- $name : string = null
-
Unique name for the router object
Return values
object —Self
pattern()
Route match pattern
public
pattern([string $pattern = null ]) : object
Parameters
- $pattern : string = null
-
Pattern used to match this rule
Return values
object —Self
resolveUrl()
Checks whether a given URL matches a given pattern.
public
resolveUrl(string $url, array<string|int, mixed> &$parameters) : bool
Parameters
- $url : string
-
The URL to check.
- $parameters : array<string|int, mixed>
-
A reference to a PHP array variable to return the parameter list fetched from URL.
Return values
bool —Returns true if the URL matches the pattern. Otherwise returns false.
captureWildcardSegments()
Captures and removes every segment of a URL after a wildcard pattern segment is detected, until both collections of segments are the same size.
protected
captureWildcardSegments(array<string|int, mixed> &$urlSegments) : array<string|int, mixed>
Parameters
- $urlSegments : array<string|int, mixed>