Route

Class to represent a route definition

package Klein

 Methods

Constructor

__construct(callable $callback, string $path, string | array $method, boolean $count_match) 
access public

Parameters

$callback

callable

$path

string

$method

stringarray

$count_match

boolean

Magic "__invoke" method

__invoke(mixed $args) : mixed

Allows the ability to arbitrarily call this instance like a function

access public

Parameters

$args

mixed

Generic arguments, magically accepted

Returns

mixed

Get the callback

getCallback() : callable
access public

Returns

callable

Get the count_match

getCountMatch() : boolean
access public

Returns

boolean

Get the method

getMethod() : string | array
access public

Returns

stringarray

Get the path

getPath() : string
access public

Returns

string

Set the callback

setCallback(callable $callback) : \Klein\Route
access public

Parameters

$callback

callable

Exceptions

\InvalidArgumentException If the callback isn't a callable

Returns

Set the count_match

setCountMatch(boolean $count_match) : \Klein\Route
access public

Parameters

$count_match

boolean

Returns

Set the method

setMethod(string | array $method) : \Klein\Route
access public

Parameters

$method

stringarray

Exceptions

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

Returns

Set the path

setPath(string $path) : \Klein\Route
access public

Parameters

$path

string

Returns

 Properties

 

$callback : callable

Any valid "callable" type is allowed

link http://php.net/manual/en/language.types.callable.php
access protected
 

$count_match : boolean
access protected
 

$method : string | array

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

Examples: - 'POST' - array('GET', 'POST')

access protected
 

$path : string

Allows for regular expression matching and/or basic string matching

Examples: - '/posts' - '/posts/[:post_slug]' - '/posts/[i:id]'

access protected