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