public function debug()
    {
        $constants = get_defined_constants(true);
        $flipped = array_flip($constants['curl']);
        $curlOpts = preg_grep('/^CURLOPT_/', $flipped);
        $curlInfo = preg_grep('/^CURLINFO_/', $flipped);

        $options = [];
        foreach ($this->getCurlOptions() as $const => $value) {
            if (isset($curlOpts[$const])) {
                $options[$curlOpts[$const]] = $value;
            } else if (isset($curlInfo[$const])) {
                $options[$curlInfo[$const]] = $value;
            } else {
                $options[$const] = $value;
            }
        }

        $className = get_class($this);
        $msg = "[{$className}] to {$this->getMethod()}={$this->getUrl()}";

        if (count($this->params) > 0) {
            $params = $this->getParams();
            if ($this->getMethod() == self::POST && $this->hasHeader('Content-Type') && $this->getHeader('Content-Type') == 'application/json') {
                $params = Json::encode($params);
            } else {
                $params = http_build_query($params);
            }

            $msg .= "\nParameters: {$params}";
        }

        if (count($options) > 0) {
            $msg .= 'CURL options: ' . print_r($options, true);
        }

        return $msg;
    }