October\Rain\Router\Rule

Source: ~/vendor/october/rain/src/Router/Rule.php

Router Rule Object

Public properties

public string $staticUrl

URL with static segments only, dynamic segments are stripped

public array $segments

Pattern segments

public int $staticSegmentCount

The number of static segments found in the pattern

public int $dynamicSegmentCount

The number of dynamic segments found in the pattern

public int $wildSegmentCount

The number of wildcard segments found in the pattern

Protected properties

protected string $ruleName

A named reference for this rule.

protected string $rulePattern

The pattern used to match this rule.

protected function $conditionCallback

Custom condition used when matching this rule.

protected function $afterMatchCallback

Called when this rule is matched.

Public methods

public void __construct(string $name, string $pattern)

Creates a new router rule instance.

Parameters
  • string $name
  • string $pattern

public callback afterMatch(callback $callback=NULL)

After match callback

Parameters
  • callback $callback - Callback function to be used to modify params after a successful match

public callback condition(callback $callback=NULL)

Condition callback

Parameters
  • callback $callback - Callback function to be used when providing custom route match conditions

public object name(string $name=NULL)

Unique route name

Parameters
  • string $name - Unique name for the router object

public object pattern(string $pattern=NULL)

Route match pattern

Parameters
  • string $pattern - Pattern used to match this rule

public boolean 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.

Protected methods

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