Build URL with query string

@param string $url
@param array $data

@return string
503771
public function parseUrl($url, array $data)
    {
        return (empty($data)) ? $url : $url . '?' . $this->parseData($data);
    }
352159
protected function http_build_multi_query($data, $key = null)
    {
        $query = [];

        if (empty($data)) {
            return $key.'=';
        }

        $is_array_assoc = $this->is_array_assoc($data);

        foreach ($data as $k => $value) {
            if (is_string($value) || is_numeric($value)) {
                $brackets = $is_array_assoc ? '['.$k.']' : '[]';
                $query[] = urlencode(null === $key ? $k : $key.$brackets).'='.rawurlencode($value);
            } else {
                if (is_array($value)) {
                    $nested = null === $key ? $k : $key.'['.$k.']';
                    $query[] = $this->http_build_multi_query($value, $nested);
                }
            }
        }

        return implode('&', $query);
    }
142651
protected function apiGet($url, $data = array())
    {
        if (!empty($data)) {
            $url = $url . "?" . http_build_query($data);
        }

        $response = $this->apiClient->get($url);

        return $this->processResponse($response);
    }
80609
private function httpBuildQuery(array $data): string
    {
        $queryString = http_build_query($data, '', '&');

        return $this->postProcessHttpQueryString($queryString, $data);
    }
1281929
public function redirect(string $url, $data = null)
    {
        return $this->response([
            'success' => true,
            'redirect' => $url,
            'data' => $data,
        ]);
    }
122146
protected function apiPost($url, $data)
    {
        if (empty($data['client_ip'])) {
            $data['client_ip'] = sprintf("%d.%d.%d.%d", rand(1, 244), rand(1, 244), rand(1, 244), rand(1, 244));
        }

        $response = $this->apiClient->post($url, array(
            'body' => $data,
        ));

        return $this->processResponse($response);
    }
842771
public function patch($url, $data = array())
    {
        if (is_array($url)) {
            $data = $url;
            $url = $this->baseUrl;
        }

        if (is_array($data) && empty($data)) {
            $this->unsetHeader('Content-Length');
        }

        $this->setURL($url);
        $this->setOpt(CURLOPT_CUSTOMREQUEST, 'PATCH');
        $this->setOpt(CURLOPT_POSTFIELDS, $this->buildPostData($data));
        return $this->exec();
    }
1200530
public static function curlHeaders($url, &$data)
    {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_NOBODY, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HEADER, true);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
        $data = curl_exec($ch);
        $headers = curl_getinfo($ch);
        curl_close($ch);

        return $headers;
    }
860635
public function addDelete($url, $query_parameters = array(), $data = array())
    {
        if (is_array($url)) {
            $data = $query_parameters;
            $query_parameters = $url;
            $url = $this->baseUrl;
        }
        $curl = new Curl();
        $curl->setURL($url, $query_parameters);
        $curl->setOpt(CURLOPT_CUSTOMREQUEST, 'DELETE');
        $curl->setOpt(CURLOPT_POSTFIELDS, $curl->buildPostData($data));
        $this->addHandle($curl);
        return $curl;
    }
446822
protected function post(string $url, array $data = []): string
    {
        $ch = \curl_init($url);
        \curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers());
        \curl_setopt($ch, CURLOPT_POST, true);
        \curl_setopt($ch, CURLOPT_COOKIE, $this->parseCookies($this->cookies));
        \curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        \curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
        \curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

        $before_curl_time = time();
        if ($this->allowRawResponceDebug)
        {
            \is_callable($this->debugCallback) && \call_user_func($this->debugCallback, [
                'before_curl' => $before_curl_time,
            ]);
        }

        $result = \curl_exec($ch);
        $error = \curl_error($ch);
        $errno = \curl_errno($ch);
        \curl_close($ch);

        if ($this->allowRawResponceDebug)
        {
            \is_callable($this->debugCallback) && \call_user_func($this->debugCallback, [
                'raw_responce' => $result,
                'error' => $error,
                'errorno' => $errno,
                'curl_delta' => time() - $before_curl_time,
            ]);
        }

        return $result;
    }
542540
function build($url,$args=[]) {
		$args+=$this->hive['PARAMS'];
		if (is_array($url))
			foreach ($url as &$var) {
				$var=$this->build($var,$args);
				unset($var);
			}
		else {
			$i=0;
			$url=preg_replace_callback('/@(\w+)|(\*)/',
				function($match) use(&$i,$args) {
					if (isset($match[1]) &&
						array_key_exists($match[1],$args))
						return $args[$match[1]];
					if (isset($match[2]) &&
						array_key_exists($match[2],$args)) {
						if (!is_array($args[$match[2]]))
							return $args[$match[2]];
						$i++;
						return $args[$match[2]][$i-1];
					}
					return $match[0];
				},$url);
		}
		return $url;
	}
623194
private function buildUrl($url)
    {
        if (!is_array($url)) {
            if (strpos($url, '://')) {
                return (string) $url;
            }
            return (string) $this->baseUrl->combine($url);
        } elseif (strpos($url[0], '://')) {
            return \GuzzleHttp\uri_template($url[0], $url[1]);
        }

        return (string) $this->baseUrl->combine(
            \GuzzleHttp\uri_template($url[0], $url[1])
        );
    }
557524
public function options($url, $data = array())
    {
        if (is_array($url)) {
            $data = $url;
            $url = $this->baseUrl;
        }
        $this->setURL($url, $data);
        $this->unsetHeader('Content-Length');
        $this->setOpt(CURLOPT_CUSTOMREQUEST, 'OPTIONS');
        return $this->exec();
    }
729364
public function post($url, $data = array())
    {
        $this->setOpt(CURLOPT_URL, $url);
        $this->preparePayload($data);
        $this->exec();
        return $this;
    }
785172
public function post($url, array $data = [])
    {
        $this->setopt(CURLOPT_URL, $url);
        $this->setopt(CURLOPT_POST, true);
        $data = http_build_query($data);
        $this->setopt(CURLOPT_POSTFIELDS, $data);
        $this->_exec();
    }
973544
public function delete($url, array $query = [], array $data = [])
    {
        $url = $this->buildUrl($url, $query);
        $handle = $this->getHandler();

        curl_setopt_array($handle, [
            CURLOPT_CUSTOMREQUEST => 'DELETE',
            CURLOPT_POSTFIELDS => http_build_query($data),
        ]);

        return $this->run($handle, $url);
    }
592573
protected function getQueryParams (array $data) {
        $add = '';
        foreach ($data as $k => $arr) {
            if (is_array($arr)) {
                foreach ($arr as $value) {
                    $add .= "&$k=" . urlencode($value);
                }
                unset($data[$k]);
            } else if ($arr === null) {
                unset($data[$k]);
            } else if (is_bool($arr)) {
                $data[$k] = $arr ? 'true' : 'false';
            }
        }

        $params = http_build_query($data) . $add;

        return $params;
    }