Factory method to create a new Uri object.

@param string $uri
@param array $params

@return GuzzleUri
347114
public function createUri($uri, array $params = [])
    {
        if ($uri instanceof GuzzleUri) {
            if (!empty($params)) {
                $uri = $uri->withQuery(http_build_query($params));
            }

            return $uri;
        }

        // If URL template given, prepare URI
        if (preg_match_all('/{[\w]+}/i', $uri, $matches)) {
            foreach (array_unique($matches[0]) as $match) {
                $param = substr($match, 1, -1);

                if (isset($params[$param])) {
                    $uri = str_replace($match, $params[$param], $uri);
                    unset($params[$param]);
                }
            }
        }

        if (!empty($params)) {
            $uri .= '?' . http_build_query($params);
        }

        return new GuzzleUri($uri);
    }
592680
private static function getResponse(string $uri, array $params = []): array
    {
        self::initialize();

        if (empty($params)) {
            $response = self::$client->get('api/' . self::$version . '/' . $uri);
        } else {
            $response = self::$client->post('api/' . self::$version . '/' . $uri, [
                'form_params' => $params,
            ]);
        }

        return json_decode($response->getBody(), TRUE);
    }
57790
public function create($uri = null, $baseuri = null)
    {
        if (empty($uri) && empty($baseuri)) {
            // Empty uri means baseurl
            return $this->baseUrl
                . (($this->urlType == self::URL_APPEND)
                    ? "/$this->scriptName"
                    : null);
        } elseif (empty($uri)) {
            // Empty uri means baseurl with appended $baseuri
            ;
        } elseif (substr($uri, 0, 7) == "http://"
            || substr($uri, 0, 8) == "https://"
            || substr($uri, 0, 2) == "//"
        ) {
            // Fully qualified, just leave as is.
            return $uri;
        } elseif ($uri[0] == "/") {
            // Absolute url, prepend with siteUrl
            //return rtrim($this->siteUrl . rtrim($uri, '/'), '/');
            return $this->siteUrl . $uri;
        } elseif ($uri[0] == "#"
            || $uri[0] == "?"
        ) {
            // Hashtag url to local page, or query part leave as is.
            return $uri;
        } elseif (substr($uri, 0, 7) == "mailto:"
            || substr(html_entity_decode($uri), 0, 7) == "mailto:") {
            // Leave mailto links as is
            // The odd fix is for markdown converting mailto: to UTF-8
            // Might be a better way to solve this...
            return $uri;
        }

        // Prepend uri with baseuri
        $uri = rtrim($uri, "/");
        if (!empty($baseuri)) {
            $uri = rtrim($baseuri, "/") . "/$uri";
        }

        // Remove the trailing index part of the url
        if (basename($uri) == "index") {
            $uri = dirname($uri);
        }

        if ($this->urlType == self::URL_CLEAN) {
            return rtrim($this->baseUrl . "/" . $uri, "/");
        } else {
            return rtrim($this->baseUrl . "/" . $this->scriptName . "/" . $uri, "/");
        }
    }
1146157
public function request($url, array $params = array())
    {
        $uri = $this->makeUri($url, $params);

        return new Psr7\Request('get', $uri);
    }
136815
public static function replaceDataUriParameters($uri, string $parameters)
    {
        $uri = self::filterUri($uri);

        return self::normalizePath($uri, (new DataPath($uri->getPath()))->withParameters($parameters));
    }
256039
public static function uri(string $uri, array $parameters = [], bool $appendsCurrentUri = false)
    {
        $uriComponents = parse_url($uri);

        if (isset($uriComponents['query'])) {
            \parse_str($uriComponents['query'], $uriComponents['query']);
        } else {
            $uriComponents['query'] = [];
        }

        if ($appendsCurrentUri) {
            $newQuery = $parameters + $_GET + $uriComponents['query'];
        } else {
            $newQuery = $parameters + $uriComponents['query'];
        }

        $newUriComponents = isset($uriComponents['scheme']) ? $uriComponents['scheme'] . '://' : '';
        $newUriComponents .= $uriComponents['host'] ?? '';
        $newUriComponents .= isset($uriComponents['port']) ? ':' . $uriComponents['port'] : '';
        $newUriComponents .= $uriComponents['path'] ?? '';
        $newUriComponents .= '?' . http_build_query($newQuery);

        return $newUriComponents;
    }
1141823
public static function createFromUri(
        $uri,
        $script = null,
        array $server = [],
        array $query = [],
        array $parsedBody = null,
        array $cookies = [],
        array $files = []
    ) {
        $server = $server ?: $_SERVER;

        if ($script) {
            $server['SCRIPT_NAME'] = $script;
        }

        $server['SCRIPT_NAME'] = '/' . ltrim($server['SCRIPT_NAME'], '/');

        $request = static::createFromGlobals($server, $query, $parsedBody, $cookies, $files);

        return $request->withUri(new PsrUri($uri));
    }
1204681
private function makeUri($url, $params = array())
    {
        $uri = \GuzzleHttp\uri_template($this->endpoint, array_merge($this->defaults, $params));
        $uri = new Psr7\Uri($uri);

        // All arguments must be urlencoded (as per RFC 1738).
        $query = Psr7\build_query($params, PHP_QUERY_RFC1738);
        $uri = $uri->withQuery($query);

        return Psr7\Uri::withQueryValue($uri, 'url', $url);
    }
18066
public function get($uri, array $params = array())
    {

        $uri .= '?' . http_build_query($params);

        $ch = $this->initCurlHandler($uri);
        return $this->makeRequest($ch);

    }
515637
protected function getResponse($uri, array $queryParams = array())
    {
        $request = $this->httpClient->get($uri, array(), array('query' => $queryParams));

        return $request->send()->json();
    }
271932
private function createRequest(array $params, array $files, $method, $url)
    {
        if (!count($params) && !count($files)) {
            return $this->factory->createRequest($method, $url);
        }

        $builder = clone $this->multipartStreamBuilder;

        foreach ($params as $k => $v) {
            $builder->addResource($k, $v);
        }

        foreach ($files as $k => $file) {
            $builder->addResource($k, fopen($file, 'r'), ['filename' => $file]);
        }

        return $this->factory->createRequest(
            $method,
            $url,
            ['Content-Type' => 'multipart/form-data; boundary=' . $builder->getBoundary()],
            $builder->build()
        );
    }
901887
public static function create($uri)
    {
        if (($parse = parse_url($uri)) === false) {
            throw new \InvalidArgumentException('Unable to parse URI');
        }

        return new Uri(
            isset($parse[ 'scheme' ])
                ? $parse[ 'scheme' ]
                : '',
            isset($parse[ 'host' ])
                ? $parse[ 'host' ]
                : '',
            isset($parse[ 'path' ])
                ? $parse[ 'path' ]
                : '',
            isset($parse[ 'port' ])
                ? $parse[ 'port' ]
                : '',
            isset($parse[ 'query' ])
                ? $parse[ 'query' ]
                : '',
            isset($parse[ 'fragment' ])
                ? $parse[ 'fragment' ]
                : '',
            isset($parse[ 'user' ])
                ? $parse[ 'user' ]
                : '',
            isset($parse[ 'pass' ])
                ? $parse[ 'pass' ]
                : ''
        );
    }
489062
public static function create($uri, $method = 'GET', array $queryOrData = [])
    {
        $method = strtoupper($method);
        $query = [];
        $data = [];
        switch ($method) {
            case 'POST':
            case 'PUT':
            case 'DELETE':
            case 'PATCH':
                $data = $queryOrData;
                break;
            default:
                $query = $queryOrData;
                break;
        }
        return new self(new Uri($uri), $method, $query, $data);
    }
556454
public static RedisURI create(String uri) {
        LettuceAssert.notEmpty(uri, "URI must not be empty");
        return create(URI.create(uri));
    }
528080
function assemble($params = null)
    {
        $uri   = new Uri;
        if ($route = $this->hasParent()) {
            $rUri = $route->assemble($params);
            $uri  = \Poirot\Psr7\modifyUri($uri, \Poirot\Psr7\parseUriPsr($rUri), \Poirot\Psr7\URI_PREPEND);
        }

        if ($preReq = $this->getPreparator())
            $uri = $preReq->withUriOnAssemble($uri);

        return $uri;
    }
82760
private function getUriRegexFromParameters($uri, $params)
    {
        $regex = str_replace('/', '\/', $uri);
        foreach ($params as $param) {
            $regex = str_replace('{' . $param . '}', '([^\/]+)', $regex);
        }
        return $regex;
    }
1009026
public static function make($uri, array $queryParameters = [])
    {
        $uri = ($uri instanceof UriInterface) ? $uri : new Uri($uri);
        if ($queryParameters) {
            $uri = static::addQueryParameters($uri, $queryParameters);
        }
        return $uri;
    }