\PhpApiRoute

Model of a Route, informs class and its method that will be triggered when a pattern is found (works with specific HTTP methods if needed)

Summary

Methods
Properties
Constants
__construct()
getPattern()
acceptPattern()
acceptHttpMethod()
getReflectionMethod()
getMethodParams()
execute()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$pattern
$class
$method
$httpMethods
N/A

Properties

$pattern

$pattern : string

The route pattern that trigger the class method

Type

string

$class

$class : string

The class of route method

Type

string

$method

$method : string

The method that will be executed

Type

string

$httpMethods

$httpMethods : array

Array of HTTP methods used to trigger. Can be GET, POST, PUT and others

Type

array

Methods

__construct()

__construct(string  $pattern, string  $class, string  $method, string  $httpMethod = null) 

Instantiate a object of Route

Parameters

string $pattern

The route pattern that trigger the class method

string $class

The class of route method

string $method

The method that will be executed

string $httpMethod

(optional) null to process any HTTP method, string to specify which one (separated by commas)

getPattern()

getPattern() : string

Returns the pattern string

Returns

string

acceptPattern()

acceptPattern(string  $pattern) : boolean

Checks if the route accepts the pattern from the request

Parameters

string $pattern

The pattern

Returns

boolean

acceptHttpMethod()

acceptHttpMethod(string  $httpMethod = null) : boolean

Checks if the route accepts the HTTP request method

Parameters

string $httpMethod

The method

Returns

boolean

getReflectionMethod()

getReflectionMethod() : \ReflectionMethod

Returns a Reflection Method object

Returns

\ReflectionMethod

getMethodParams()

getMethodParams() : array

Returns all the methods params

Returns

array

execute()

execute(array  $params = null) 

Executes the class method and its parameters (if needed)

Parameters

array $params

Method parameters