Skip to content

Commit

Permalink
Update RouteInterface.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Apatis authored Jan 28, 2018
1 parent 4d934cf commit 8de4f16
Showing 1 changed file with 61 additions and 52 deletions.
113 changes: 61 additions & 52 deletions src/RouteInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,114 +25,123 @@

namespace Apatis\Route;

use FastRoute\Dispatcher;
use FastRoute\RouteParser;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

/**
* Interface RouterInterface
* Interface RouteInterface
* @package Apatis\Route
*/
interface RouterInterface
interface RouteInterface extends RoutAbleInterface
{
/**
* Add route
* RouteInterface constructor.
*
* @param array $methods
* @param string $pattern
* @param callable $callable
*
* @return RouteInterface
* @param array $groups
* @param int $identifier
*/
public function map(array $methods, string $pattern, $callable) : RouteInterface;
public function __construct(
array $methods,
string $pattern,
$callable,
array $groups = [],
int $identifier = 0
);

/**
* Dispatch router for HTTP request
* Set route name
*
* @param ServerRequestInterface $request The current HTTP request object
*
* @return array
* @param string $name
*
* @link https://github.com/nikic/FastRoute/blob/master/src/Dispatcher.php
* @return static
*/
public function dispatch(ServerRequestInterface $request) : array;
public function setName(string $name) : RouteInterface;

/**
* Add a route group to the array
*
* @param string $pattern The group pattern
* @param callable $callable A group callable
* Get route defined name
*
* @return RouteGroupInterface
* @return string|null return string if route name has been set
*/
public function pushGroup(string $pattern, $callable) : RouteGroupInterface;
public function getName();

/**
* Removes the last route group from the array
* Set argument
*
* @return RouteGroupInterface|null
* @param string|float|int $name
* @param mixed $value
*
* @return RouteInterface
*/
public function popGroup();
public function setArgument($name, $value) : RouteInterface;

/**
* Get named route object
* Get argument by name
*
* @param string $name Route name
* @param string|float|int $name
* @param null $default
*
* @return RouteInterface|null
* @return mixed|null
*/
public function getRouteByName(string $name);
public function getArgument($name, $default = null);

/**
* @param string $name
* Get all arguments
*
* @param array $arguments
*
* @return bool
* @return static
*/
public function removeRouteByName(string $name) : bool;
public function setArguments(array $arguments) : RouteInterface;

/**
* @param int $identifier
*
* @return RouteInterface|null
* @return array
*/
public function getRouteByIdentifier(int $identifier);
public function getArguments() : array;

/**
* Get route collection
* Get defined pattern
*
* @return RouteInterface[]
* @return string
*/
public function getRoutes() : array;
public function getPattern() : string;

/**
* Set Route Dispatcher
*
* @param Dispatcher $dispatcher
* Get route Identifier
*
* @return RouterInterface
* @return int
*/
public function setDispatcher(Dispatcher $dispatcher) : RouterInterface;
public function getIdentifier() : int;

/**
* Get route Dispatcher
* Prepare Route process
*
* @return Dispatcher|null
* @param ServerRequestInterface $request
* @param array $arguments
*
* @return mixed
*/
public function getDispatcher();
public function prepare(ServerRequestInterface $request, array $arguments);

/**
* Set RouteParser
* Run the route
*
* @param RouteParser $routeParser
* @param ServerRequestInterface $request
* @param ResponseInterface $response
*
* @return RouterInterface
* @return ResponseInterface
*/
public function setRouteParser(RouteParser $routeParser) : RouterInterface;
public function process(ServerRequestInterface $request, ResponseInterface $response) : ResponseInterface;

/**
* Get Route Parser
* Invoke callable
*
* @param ServerRequestInterface $request
* @param ResponseInterface $response
*
* @return RouteParser
* @return ResponseInterface
*/
public function getRouteParser() : RouteParser;
public function __invoke(ServerRequestInterface $request, ResponseInterface $response) : ResponseInterface;
}

0 comments on commit 8de4f16

Please sign in to comment.