*/
namespace PHPRouter;
+use Fig\Http\Message\RequestMethodInterface;
+
class Route
{
/**
* Accepted HTTP methods for this route.
* @var string[]
*/
- private $methods = array('GET', 'POST', 'PUT', 'DELETE');
+ private $methods = array(
+ RequestMethodInterface::METHOD_GET,
+ RequestMethodInterface::METHOD_POST,
+ RequestMethodInterface::METHOD_PUT,
+ RequestMethodInterface::METHOD_DELETE,
+ );
/**
* Target for this route, can be anything.
namespace PHPRouter;
use Exception;
-use PHPRouter\RouteCollection;
+use Fig\Http\Message\RequestMethodInterface;
/**
* Routing class to match request URL's against given routes and map them to a controller action.
$requestMethod = (
isset($_POST['_method'])
&& ($_method = strtoupper($_POST['_method']))
- && in_array($_method, array('PUT', 'DELETE'))
+ && in_array($_method, array(RequestMethodInterface::METHOD_PUT, RequestMethodInterface::METHOD_DELETE), true)
) ? $_method : $_SERVER['REQUEST_METHOD'];
$requestUrl = $_SERVER['REQUEST_URI'];
*
* @return bool|Route
*/
- public function match($requestUrl, $requestMethod = 'GET')
+ public function match($requestUrl, $requestMethod = RequestMethodInterface::METHOD_GET)
{
foreach ($this->routes->all() as $routes) {
// compare server request method with route's allowed http methods