class Rule

Router Rule Object

Adapted from october\rain\router\Rule

Properties

protected string $ruleName
protected string $rulePattern
protected Closure $conditionCallback
protected Closure $afterMatchCallback
string $staticUrl
array $segments
int $staticSegmentCount
int $dynamicSegmentCount
int $wildSegmentCount

Methods

__construct(string $name, string $pattern)

Creates a new router rule instance.

bool
resolveUrl(string $url, array $parameters)

Checks whether a given URL matches a given pattern.

array
captureWildcardSegments(array $urlSegments)

Captures and removes every segment of a URL after a wildcard pattern segment is detected, until both collections of segments are the same size.

object
name(string $name = null)

Unique route name

object
pattern(string $pattern = null)

Route match pattern

callable
condition(callable $callback = null)

Condition callback

callable
afterMatch(callable $callback = null)

After match callback

Details

at line 66
__construct(string $name, string $pattern)

Creates a new router rule instance.

Parameters

string $name
string $pattern

at line 99
bool resolveUrl(string $url, array $parameters)

Checks whether a given URL matches a given pattern.

Parameters

string $url

The URL to check.

array $parameters

A reference to a PHP array variable to return the parameter list fetched from URL.

Return Value

bool

Returns true if the URL matches the pattern. Otherwise returns false.

at line 219
protected array captureWildcardSegments(array $urlSegments)

Captures and removes every segment of a URL after a wildcard pattern segment is detected, until both collections of segments are the same size.

Parameters

array $urlSegments

Return Value

array

at line 257
object name(string $name = null)

Unique route name

Parameters

string $name

Unique name for the router object

Return Value

object Self

at line 274
object pattern(string $pattern = null)

Route match pattern

Parameters

string $pattern

Pattern used to match this rule

Return Value

object Self

at line 292
callable condition(callable $callback = null)

Condition callback

Parameters

callable $callback

Callback function to be used when providing custom route match conditions

Return Value

callable

Exceptions

InvalidArgumentException

at line 317
callable afterMatch(callable $callback = null)

After match callback

Parameters

callable $callback

Callback function to be used to modify params after a successful match

Return Value

callable

Exceptions

InvalidArgumentException