Fixes typo
This commit is contained in:
+17
-10
@@ -33,24 +33,29 @@ class Router {
|
||||
return $this->request('post', $path, $callback);
|
||||
}
|
||||
|
||||
public function patch(string $path, callable $callack) {
|
||||
return $this->request('patch', $path, $callack);
|
||||
public function patch(string $path, callable $callback) {
|
||||
return $this->request('patch', $path, $callback);
|
||||
}
|
||||
|
||||
public function delete(string $path, callable $callack) {
|
||||
return $this->request('delete', $path, $callack);
|
||||
public function delete(string $path, callable $callback) {
|
||||
return $this->request('delete', $path, $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RouteNotFoundException
|
||||
*/
|
||||
public function dispatch() {
|
||||
$requestMethod = strtolower($_SERVER['REQUEST_METHOD']);
|
||||
$requestUri = parse_url($_SERVER['REQUEST_URI']);
|
||||
foreach ($this->routes as $route) {
|
||||
$path = str_replace('/', '\/', $route->path);
|
||||
$path = '/^' . $path . '\/?$/';
|
||||
if (in_array($requestMethod, $this->allowedMethods, true) && $requestMethod === $route->method && preg_match($path, $requestUri['path'], $params) === 1) {
|
||||
array_shift($params);
|
||||
call_user_func_array($route->callback, $params);
|
||||
exit;
|
||||
if (in_array($requestMethod, $this->allowedMethods, true)
|
||||
&& $requestMethod === $route->method
|
||||
&& preg_match($path, $requestUri['path'], $params) === 1) {
|
||||
array_shift($params);
|
||||
call_user_func_array($route->callback, $params);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
http_response_code(404);
|
||||
@@ -63,8 +68,10 @@ class Router {
|
||||
foreach ($this->routes as $route) {
|
||||
$path = str_replace('/', '\/', $route->path);
|
||||
$path = '/^' . $path . '\/?$/';
|
||||
if (in_array($requestMethod, $this->allowedMethods, true) && $requestMethod === $route->method && preg_match($path, $requestUri['path'], $params) === 1) {
|
||||
return true;
|
||||
if (in_array($requestMethod, $this->allowedMethods, true)
|
||||
&& $requestMethod === $route->method
|
||||
&& preg_match($path, $requestUri['path'], $params) === 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user