public static function fromEnvironment(): RequestInterface
    {
        $headers = [];
        foreach ($_SERVER as $name => $value) {
            if (strpos($name, 'HTTP_') === 0) {
                $name = substr($name, 5);
                $name = str_replace('_', ' ', $name);
                $name = strtolower($name);
                $name = ucwords($name);
                $name = str_replace(' ', '-', $name);

                $headers[$name] = $value;
            }
        }

        $input = file_get_contents('php://input') ?: '';
        if (empty($input) === false) {
            $body = json_decode(file_get_contents('php://input') ?: '');
            if (json_last_error() !== JSON_ERROR_NONE) {
                throw new InvalidRequestBody(json_last_error_msg());
            }
        }

        return (new static())
            ->withMethod($_SERVER['REQUEST_METHOD'])
            ->withBody($body ?? null)
            ->withHeaders($headers)
            ->withUri(Uri::fromEnvironment());
    }