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 0d14c96 commit 4d934cf
Showing 1 changed file with 52 additions and 61 deletions.
113 changes: 52 additions & 61 deletions src/RouteInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,123 +25,114 @@

namespace Apatis\Route;

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

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

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

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

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

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

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

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

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

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

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

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

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

0 comments on commit 4d934cf

Please sign in to comment.