protected function buildUrl($url, $query = [])
    {
        $url = explode('?', $url, 2);
        if (count($url) == 2) {
            parse_str($url[1], $query0);
            $query = array_merge($query0, $query);
        }
        $query['apikey'] = $this->key;

        $url = $url[0];

        if (strpos($url, $this->baseUrl) === false) {
            $url = $this->baseUrl . $url;
        }

        return $this->uriFactory->createUri($url)
            ->withQuery(http_build_query($query));
    }
protected function buildUrl($url, $query = [])
    {
        $url = explode('?', $url, 2);
        if (count($url) == 2) {
            parse_str($url[1], $query0);
            $query = array_merge($query0, $query);
        }
        $query['apikey'] = $this->key;

        $url = $url[0];

        if (strpos($url, $this->baseUrl) === false) {
            $url = $this->baseUrl . $url;
        }

        return $this->uriFactory->createUri($url)
            ->withQuery(http_build_query($query));
    }
protected function buildUrl ( $ url , $ query = [ ] ) { $ url = explode ( '?' , $ url , 2 ) ; if ( count ( $ url ) == 2 ) { parse_str ( $ url [ 1 ] , $ query0 ) ; $ query = array_merge ( $ query0 , $ query ) ; } $ query [ 'apikey' ] = $ this -> key ; $ url = $ url [ 0 ] ; if ( strpos ( $ url , $ this -> baseUrl ) === false ) { $ url = $ this -> baseUrl . $ url ; } return $ this -> uriFactory -> createUri ( $ url ) -> withQuery ( http_build_query ( $ query ) ) ; }
Extend an URL with query string parameters and return an UriInterface object.

@param string $url
@param array  $query

@return UriInterface
Extend an URL with query string parameters and return an UriInterface object .