Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@joshuaadickerson
Created March 13, 2016 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuaadickerson/040285af00a25d7fa63c to your computer and use it in GitHub Desktop.
Save joshuaadickerson/040285af00a25d7fa63c to your computer and use it in GitHub Desktop.
I just found this in Notepad++ so I'm adding it to gist so I can close it. I don't know what I was working on
<?php
interface RouteInterface {
public $regex;
public $methods = array();
public $handler;
protected $data;
/**
* @param string|array $method
* @param string $regex
* @param mixed $handler
*/
public function __construct($method, $regex, $handler);
/**
* Check if this route matches the request string
*
* @param string $request_string
* @return boolean
*/
public function match($request_string);
/**
* Check if this route matches the method
*
* @param string $method
* @return boolean
*/
public function hasMethod($method);
/**
* @return array
*/
public function getData();
/**
* @return mixed usually a callable
*/
public function getHandler();
}
interface RouterInterface {
const METHOD_GET = 'GET';
const METHOD_POST = 'POST';
const METHOD_PUT = 'PUT';
const METHOD_DELETE = 'DELETE';
/**
* @param array $methods One of self::METHOD_*
* @param string $regex
* @param mixed $handler
* @return RouterInterface
*/
public function match(array $methods, $regex, $handler);
public function get($regex, $handler);
public function post($regex, $handler);
public function put($regex, $handler);
public function delete($regex, $handler);
public function getRoutes();
}
interface DispatcherInterface {
const ROUTE_NOT_FOUND = 0;
const ROUTE_FOUND = 1;
public function __construct(Router $router);
/**
* @param string $method
* @param string $request_string
* @return int
*/
public function dispatch($method, $request_string);
}
class UnknownRouteException extends RuntimeException {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment