Basicis - Core

Logo

As the name says, it is made to be basic and direct.

View the Project on GitHub basicis/core

Basicis\Router\Router

Router Class

Methods

Name Description
__construct Function __constructs
__invoke Function __invoke
Handles a request and produces a response.  
extractArgId Function extractArgId
Extract a argument id/name of route name part  
extractArgRegex Function extractArgRegex
Extract a argument regex of route name part  
findByCount Function findByCount
Find all routes by count spaces bar “/”  
findByMethod Function findByMethod
Find all routes by method  
findByName Function findByName
Find a route by name/url  
findByRegex Function findByRegex
Find a route by regular expression  
getResponse Function getResponse
Get a ResponseInterface Object or router run  
getRoute Function getRoute
Get route requested  
getRoutes Function getRoutes
Get a array with all routes into instance of router  
handle Function __invoke
Handles a request and produces a response.  
hasRoute Function hasRoute
Check if route match exists for name and method  
setRequest Function getResponse
Set a ServerRequestInterface Object for router run  
setRoute Function setRoute
Set a route for router  
setRouteByAnnotation Function setRouteByAnnotation
Receives a class as an argument, and works with the comment blocks as @Route  

Router::__construct

Description

public __construct (void)

Function __constructs

Parameters

This function has no parameters.

Return Values

void


Router::__invoke

Description

public __invoke (\ServerRequestInterface $request, \ResponseInterface $response, callable $next)

Function __invoke Handles a request and produces a response.

May call other collaborating code to generate the response.

Parameters

Return Values

\ResponseInterface


Router::extractArgId

Description

public extractArgId (string $routeNamePart)

Function extractArgId Extract a argument id/name of route name part

Parameters

Return Values

string|null


Router::extractArgRegex

Description

public extractArgRegex (string $routeNamePart)

Function extractArgRegex Extract a argument regex of route name part

Parameters

Return Values

string|null


Router::findByCount

Description

public findByCount (string $url, array $routes)

Function findByCount Find all routes by count spaces bar “/”

Parameters

Return Values

\Route[]


Router::findByMethod

Description

public findByMethod (string $url, array $routes)

Function findByMethod Find all routes by method

Parameters

Return Values

array


Router::findByName

Description

public findByName (string $url)

Function findByName Find a route by name/url

Parameters

Return Values

array


Router::findByRegex

Description

public findByRegex (string $url)

Function findByRegex Find a route by regular expression

Parameters

Return Values

array|null


Router::getResponse

Description

public getResponse (void)

Function getResponse Get a ResponseInterface Object or router run

Parameters

This function has no parameters.

Return Values

\ResponseInterface


Router::getRoute

Description

public getRoute (string $url, string $method)

Function getRoute Get route requested

Parameters

Return Values

\Route|null


Router::getRoutes

Description

public getRoutes (void)

Function getRoutes Get a array with all routes into instance of router

Parameters

This function has no parameters.

Return Values

array|\Route[]


Router::handle

Description

public handle (\ServerRequestInterface $request, \ResponseInterface $response, callable $next)

Function __invoke Handles a request and produces a response.

May call other collaborating code to generate the response.

Parameters

Return Values

\ResponseInterface


Router::hasRoute

Description

public hasRoute (string $name, string $method)

Function hasRoute Check if route match exists for name and method

Parameters

Return Values

bool


Router::setRequest

Description

public setRequest (void)

Function getResponse Set a ServerRequestInterface Object for router run

Parameters

This function has no parameters.

Return Values

\ServerRequestInterface


Router::setRoute

Description

public setRoute (string|array $url, string|array $method, string|\Clousure $callback, string|array $middlewares)

Function setRoute Set a route for router

Parameters

Return Values

\Router


Router::setRouteByAnnotation

Description

public setRouteByAnnotation (string $annotation, string $callback)

Function setRouteByAnnotation Receives a class as an argument, and works with the comment blocks as @Route

Parameters

Return Values

void