public static function toUriString(Request $request)
    {
        $uri = clone $request->getUri();

        $uri->setQuery(array_merge($uri->getQueryAsArray(),
            $request->getQuery()->toArray()));

        return $uri->toString();
    }