\app\framework\Component\Route\KleinRoute

Route

Class to represent a route definition

Summary

Methods
Properties
Constants
__construct()
getCallback()
setCallback()
getPath()
setPath()
getMethod()
setMethod()
getCountMatch()
setCountMatch()
getName()
setName()
__invoke()
No public properties found
No constants found
No protected methods found
$callback
$path
$method
$count_match
$name
N/A
No private methods found
No private properties found
N/A

Properties

$callback

$callback : 

The callback method to execute when the route is matched

Any valid "callable" type is allowed

Type

$path

$path : 

The URL path to match

Allows for regular expression matching and/or basic string matching

Examples:

  • '/posts'
  • '/posts/[:post_slug]'
  • '/posts/[i:id]'

Type

$method

$method : 

The HTTP method to match

May either be represented as a string or an array containing multiple methods to match

Examples:

  • 'POST'
  • array('GET', 'POST')

Type

$count_match

$count_match : 

Whether or not to count this route as a match when counting total matches

Type

$name

$name : 

The name of the route

Mostly used for reverse routing

Type

Methods

__construct()

__construct(callable  $callback, string  $path = null, string|array  $method = null, boolean  $count_match = true,   $name = null) 

Constructor

Parameters

callable $callback
string $path
string|array $method
boolean $count_match
$name

getCallback()

getCallback() : callable

Get the callback

Returns

callable

setCallback()

setCallback(callable  $callback) : \app\framework\Component\Route\Klein\Route

Set the callback

Parameters

callable $callback

Throws

\InvalidArgumentException

If the callback isn't a callable

Returns

\app\framework\Component\Route\Klein\Route

getPath()

getPath() : string

Get the path

Returns

string

getMethod()

getMethod() : string|array

Get the method

Returns

string|array

setMethod()

setMethod(string|array|null  $method) : \app\framework\Component\Route\Klein\Route

Set the method

Parameters

string|array|null $method

Throws

\InvalidArgumentException

If a non-string or non-array type is passed

Returns

\app\framework\Component\Route\Klein\Route

getCountMatch()

getCountMatch() : boolean

Get the count_match

Returns

boolean

getName()

getName() : string

Get the name

Returns

string

__invoke()

__invoke(mixed  $args = null) : mixed

Magic "__invoke" method

Allows the ability to arbitrarily call this instance like a function

Parameters

mixed $args

Generic arguments, magically accepted

Returns

mixed