tinyrouter.class.php


namespace iml

Axels first router

––––––––––––––––––––––––––––––––––––––––

THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE PROGRAM ?AS IS? WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
SERVICING, REPAIR OR CORRECTION.

––––––––––––––––––––––––––––––––––––––––
*


public function __construct($aRoutes=[],$sUrl=false)

constructor Parameters:

Var Type Desciption
array $aRoutes array of routes
string $sUrl incoming url

Return:

boolean


protected function _getRoute()

detect last matching route item if no route matches then it returns false Return:

array


public function setRoutes($aRoutes=[])

set routes Parameters:

Var Type Desciption
$aRoutes array list of [ route, more params … ]

Return:

boolean


public function setUrl($sUrl)

set incoming url, add the request behind protocol and domain. Parameters:

Var Type Desciption
sUrl string url to fetch; /api/v1/productbyid/3424084

Return:

boolean


public function getUrlParts($sUrl=false)

helper function: get url request parts as array Parameters:

Var Type Desciption
$sUrl string url to handle; /api/v1/productbyid/3424084

Return:

array


public function getRoute()

detect last matching route item if no route matches then it returns false Return:

array|bool


public function getCallback()

return the callback iten of the matching route If no route was matching it returns false Return:

{*}


public function getVars()

return the variables as keys in route parts with starting @ character Return:

array


public function getVar($sVarname)

return the variables as keys in route parts with starting @ character Return:

string


public function getSubitems()

get an array with next level route entries releative to the current route Return:

array