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