getHeaderLine('Authorization') ?? ''; if (strlen($token) > 0) { try { $token = JWTUtil::handleToken($token); if ($token !== false && $this->jwt->checkToken($token)) { $isValidToken = true; } } catch (InvalidArgumentException $e) { throw new TokenValidException('Token authentication does not pass', 401); } } if ($isValidToken) { return $handler->handle($request); } throw new TokenValidException('Token authentication does not pass', 401); } }