public static function toCake(PsrRequest $request)
    {
        $post = $request->getParsedBody();
        $headers = [];
        foreach ($request->getHeaders() as $k => $value) {
            $name = sprintf('HTTP_%s', strtoupper(str_replace('-', '_', $k)));
            $headers[$name] = implode(',', $value);
        }
        $server = $headers + $request->getServerParams();

        $files = static::getFiles($request);
        if (!empty($files)) {
            $post = Hash::merge($post, $files);
        }

        $input = $request->getBody()->getContents();
        $input = $input === '' ? null : $input;

        return new ServerRequest([
            'query' => $request->getQueryParams(),
            'post' => $post,
            'cookies' => $request->getCookieParams(),
            'environment' => $server,
            'params' => static::getParams($request),
            'url' => $request->getUri()->getPath(),
            'base' => $request->getAttribute('base', ''),
            'webroot' => $request->getAttribute('webroot', '/'),
            'session' => $request->getAttribute('session', null),
            'input' => $input,
        ]);
    }