yii\httpclient\CurlTransport::composeCurlOptions PHP Method

composeCurlOptions() private method

Composes cURL options from raw request options.
private composeCurlOptions ( array $options ) : array
$options array raw request options.
return array cURL options, in format: [curl_constant => value].
    private function composeCurlOptions(array $options)
    {
        static $optionMap = ['protocolVersion' => CURLOPT_HTTP_VERSION, 'maxRedirects' => CURLOPT_MAXREDIRS, 'sslCapath' => CURLOPT_CAPATH, 'sslCafile' => CURLOPT_CAINFO];
        $curlOptions = [];
        foreach ($options as $key => $value) {
            if (is_int($key)) {
                $curlOptions[$key] = $value;
            } else {
                if (isset($optionMap[$key])) {
                    $curlOptions[$optionMap[$key]] = $value;
                } else {
                    $key = strtoupper($key);
                    if (strpos($key, 'SSL') === 0) {
                        $key = substr($key, 3);
                        $constantName = 'CURLOPT_SSL_' . $key;
                        if (!defined($constantName)) {
                            $constantName = 'CURLOPT_SSL' . $key;
                        }
                    } else {
                        $constantName = 'CURLOPT_' . strtoupper($key);
                    }
                    $curlOptions[constant($constantName)] = $value;
                }
            }
        }
        return $curlOptions;
    }