PHP Class Ergo\Routing\Route

Parses routes with parameters in them e.g
http://example.org/{myparam}
http://example.org/{myparam:integer}
http://example.org/{myparam:string}
http://example.org/{myparam}/{myparam2}?test={myparam3}
Mostra file Open project: 99designs/ergo

Public Methods

Method Description
__construct ( string $name, string $template )
getMatch ( $path, $metadata = null ) : RouteMatch
getName ( ) Returns the route name of the entry
getParameterNames ( ) : array Returns the names of the replaceable parameters defined in this route
interpolate ( array $parameters ) : string

Protected Methods

Method Description
_getMatches ( string $path ) : array Finds route pattern matches for the given path.

Private Methods

Method Description
_escapeTemplate ( string $template ) : string Escape for regex except for curly braces, which are pulled out later.
_extractParameterNames ( string $template ) : array
_getParameterPattern ( string $template ) : array Gets a pattern that can be used for parsing a template
_interpolateCallback ( $matches ) A callback for preg_replace_callback() that returns interpolation parameters
_typePatternCallback ( $matches ) A callback for preg_replace_callback() that returns pattern chunks for a type

Method Details

__construct() public method

public __construct ( string $name, string $template )
$name string
$template string

_getMatches() protected method

Returns empty array if no matches found (indicating route doesn't match $path).
protected _getMatches ( string $path ) : array
$path string
return array

getMatch() public method

public getMatch ( $path, $metadata = null ) : RouteMatch
return RouteMatch or null if no match.

getName() public method

Returns the route name of the entry
public getName ( )

getParameterNames() public method

Returns the names of the replaceable parameters defined in this route
public getParameterNames ( ) : array
return array

interpolate() public method

public interpolate ( array $parameters ) : string
$parameters array
return string