public static function fromArray(Array $data)
    {
        $request = new static();

        if (!isset($data['body']) || !isset($data['request'])) {
            throw new UnexpectedValueException(
                'Unexpected data, invalid data'
            );
        }

        $body = $data['body'];
        $params = $data['request'];

        $request->setTimestamp(microtime(true));

        if (isset($params['RequestURI'])) {
            $request->setRequestUrl($params['RequestURI']);
        }

        if (isset($params['Method'])) {
            $request->setRequestMethod($params['Method']);
        }

        if (isset($params['Header']) && is_array($params['Header'])) {
            $headers = $params['Header'];

            if (isset($params['Host'])) {
                $headers['Host'] = [$params['Host']];
            }

            $request->setHeaders($headers);

            //Malformed cookies will return a fatal error
            $cookies = $cookies = new Cookie($request->getHeader('Cookie'));
            if ($cookies) {
                $request->setCookies($cookies);
            }
        }

        if (isset($params['URL']['RawQuery'])) {
            parse_str($params['URL']['RawQuery'], $queryFields);
            $request->setQueryFields($queryFields);
        }

        if (isset($params['Host']) && isset($params['Proto'])) {
            $info = parse_url($params['Host']);
            $info['proto'] = $params['Proto'];

            $request->setServerInfo($info);
        }

        if (isset($params['RemoteAddr'])) {
            $info = parse_url($params['RemoteAddr']);
            $request->setRemoteInfo($info);
        }

        if (strlen($body)) {
            parse_str($body, $postFields);
            $request->setPostFields($postFields);
        }

        return $request;
    }