Change switch to match.
This commit is contained in:
parent
e2094ccb4a
commit
cd01ab9e72
@ -328,24 +328,13 @@ class Router {
|
||||
*/
|
||||
public static function apply(): void {
|
||||
$path = static::currentPath();
|
||||
$routers = [];
|
||||
switch ($_SERVER['REQUEST_METHOD']){ // Según el método selecciona un arreglo de routers configurados
|
||||
case 'POST':
|
||||
$routers = static::$post;
|
||||
break;
|
||||
case 'PUT':
|
||||
$routers = static::$put;
|
||||
break;
|
||||
case 'PATCH':
|
||||
$routers = static::$patch;
|
||||
break;
|
||||
case 'DELETE':
|
||||
$routers = static::$delete;
|
||||
break;
|
||||
default:
|
||||
$routers = static::$get;
|
||||
break;
|
||||
}
|
||||
$routers = match($_SERVER['REQUEST_METHOD']) { // Según el método selecciona un arreglo de routers configurados
|
||||
'POST' => static::$post,
|
||||
'PUT' => static::$put,
|
||||
'PATCH' => static::$patch,
|
||||
'DELETE' => static::$delete,
|
||||
default => static::$get
|
||||
};
|
||||
|
||||
$req = static::getReq();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user