action = $action; $this->isAuthRequired = $isAuthRequired; } public function isAuthRequired(): bool { return $this->isAuthRequired; } /** * Runs an action * @param mixed[] $params * @param S $session * @return HttpResponse */ public function run(array $params, $session): HttpResponse { $params = array_values($params); $params[] = $session; return call_user_func_array($this->action, $params); } /** * @param callable(mixed[], S): HttpResponse $action * @return Action an action that does not require to have an authorization. */ public static function noAuth(callable $action): Action { return new Action($action, false); } /** * @param callable(mixed[], S): HttpResponse $action * @return Action an action that does require to have an authorization. */ public static function auth(callable $action): Action { return new Action($action, true); } }