\Gishiki\Core\RouterMatchableRouteTrait

Working implementation of RouteInterface ready to be implemented by a route.

Written to ease the process of extending the Router component with routes written by third-parties and reducing my own codebase.

Summary

Methods
Properties
Constants
getURI()
getStatus()
getMethods()
matches()
matchURI()
No public properties found
No constants found
paramCheck()
matchCheck()
$route
N/A
No private methods found
No private properties found
N/A

Properties

$route

$route : array

uri => string (begins with / example: "/do_something") status => integer (the HTTP return status code, used for error handling) verbs => string[] (the array of string of allowed/matchable HTTP methods)

Type

array — the route definition

Methods

getURI()

getURI() 

getStatus()

getStatus() 

getMethods()

getMethods() 

matches()

matches(string  $method, string  $url, array  $matchedExpr, array  $matchedGet) : boolean

Check if the given URL matches the route URI.

Also fill GET and expressions parameters.

Parameters

string $method

the HTTP method used on the Request

string $url

the URL invoked

array $matchedExpr

will be filled with an associative array of paramName => urlValue

array $matchedGet

will be filled with an associative array of paramName => urlValue (reserved for get parameters)

Returns

boolean —

true if the given method and url matches this route

matchURI()

matchURI(string  $uri, string  $url, array  $matchedExpr, array  $matchedGet) : boolean

Check if the given URL matches the given URI.

$matchedExpr is given as an associative array: name => value

Parameters

string $uri

the URI to be matched against the given URL

string $url

the URL to be matched

array $matchedExpr

the variable to be filled with matched parameters

array $matchedGet

the variable to be filled with GET options

Returns

boolean —

true if the URL matches the URI, false otherwise

paramCheck()

paramCheck(  $urlSplit,   $type) : boolean

Check if a piece of URL matches a parameter of the given type.

List of types:

  • 0 unsigned integer
  • 1 signed integer
  • 2 float
  • 3 string
  • 4 email

Parameters

$urlSplit

string the piece of URL to be checked

$type

int the type of accepted parameter

Throws

\Gishiki\Core\Router\RouterException

the given type is invalid

Returns

boolean —

true on success, false otherwise

matchCheck()

matchCheck(string  $uriSplit, string  $urlSplit, mixed  $params) : boolean

Check weather a piece of an URL matches the corresponding piece of URI

Parameters

string $uriSplit

the slice of URI to be checked

string $urlSplit

the slice of URL to be checked

mixed $params

used to register the correspondence (if any)

Returns

boolean —

true if the URL slice matches the URI slice, false otherwise