protected function sendRequest($url, array $params, $method)
    {
        $method = strtolower($method);
        $options = [
            CURLOPT_RETURNTRANSFER => true,
        ];

        if (self::REQUEST_METHOD_GET === $method) {
            $url .= '?' . http_build_query($params);
        } else {
            $options[CURLOPT_POST] = true;
            $options[CURLOPT_POSTFIELDS] = http_build_query($params);
        }

        $ch = curl_init($url);
        curl_setopt_array($ch, $options);
        $response = curl_exec($ch);

        if (!$response) {
            throw new \RuntimeException('cURL: ' . curl_error($ch), curl_errno($ch));
        }
        curl_close($ch);

        return $response;
    }
protected function sendRequest($url, array $params, $method)
    {
        $method = strtolower($method);
        $options = [
            CURLOPT_RETURNTRANSFER => true,
        ];

        if (self::REQUEST_METHOD_GET === $method) {
            $url .= '?' . http_build_query($params);
        } else {
            $options[CURLOPT_POST] = true;
            $options[CURLOPT_POSTFIELDS] = http_build_query($params);
        }

        $ch = curl_init($url);
        curl_setopt_array($ch, $options);
        $response = curl_exec($ch);

        if (!$response) {
            throw new \RuntimeException('cURL: ' . curl_error($ch), curl_errno($ch));
        }
        curl_close($ch);

        return $response;
    }
protected function sendRequest ( $ url , array $ params , $ method ) { $ method = strtolower ( $ method ) ; $ options = [ CURLOPT_RETURNTRANSFER => true , ] ; if ( self :: REQUEST_METHOD_GET === $ method ) { $ url .= '?' . http_build_query ( $ params ) ; } else { $ options [ CURLOPT_POST ] = true ; $ options [ CURLOPT_POSTFIELDS ] = http_build_query ( $ params ) ; } $ ch = curl_init ( $ url ) ; curl_setopt_array ( $ ch , $ options ) ; $ response = curl_exec ( $ ch ) ; if ( ! $ response ) { throw new \ RuntimeException ( 'cURL: ' . curl_error ( $ ch ) , curl_errno ( $ ch ) ) ; } curl_close ( $ ch ) ; return $ response ; }
Send request and return response.

Protected for phpUnit mocking.

@param string $url    URL
@param array  $params `GET` or `POST` parameters.
@param string $method `GET` or `POST` method.

@return string
Send request and return response .