protected function setOptions(array $options)
    {
        // change case of the keys
        $defaults = array_change_key_case($this->getDefaultOptions(), CASE_UPPER);
        $options = array_change_key_case($options, CASE_UPPER);
        $options = array_merge($defaults, $options);

        // set base uri if defined
        if(array_key_exists('BASE_URI', $options)) {
            $this->base_uri = $options['BASE_URI'];
        }

        // set the headers
        if(array_key_exists('HEADERS', $options) && is_array($options['HEADERS'])) {
            $this->setHeaders($options['HEADERS']);
        }

        // set proper curl options
        foreach ($options as $key => $value) {
            $cst_name = 'CURLOPT_'.strtoupper(trim($key));
            $cst =  defined($cst_name) ? constant($cst_name) : null;
            if($cst !== null) {
                curl_setopt($this->request, $cst, $value);
            }
        }
    }
protected function setOptions(array $options)
    {
        // change case of the keys
        $defaults = array_change_key_case($this->getDefaultOptions(), CASE_UPPER);
        $options = array_change_key_case($options, CASE_UPPER);
        $options = array_merge($defaults, $options);

        // set base uri if defined
        if(array_key_exists('BASE_URI', $options)) {
            $this->base_uri = $options['BASE_URI'];
        }

        // set the headers
        if(array_key_exists('HEADERS', $options) && is_array($options['HEADERS'])) {
            $this->setHeaders($options['HEADERS']);
        }

        // set proper curl options
        foreach ($options as $key => $value) {
            $cst_name = 'CURLOPT_'.strtoupper(trim($key));
            $cst =  defined($cst_name) ? constant($cst_name) : null;
            if($cst !== null) {
                curl_setopt($this->request, $cst, $value);
            }
        }
    }
protected function setOptions ( array $ options ) { // change case of the keys $ defaults = array_change_key_case ( $ this -> getDefaultOptions ( ) , CASE_UPPER ) ; $ options = array_change_key_case ( $ options , CASE_UPPER ) ; $ options = array_merge ( $ defaults , $ options ) ; // set base uri if defined if ( array_key_exists ( 'BASE_URI' , $ options ) ) { $ this -> base_uri = $ options [ 'BASE_URI' ] ; } // set the headers if ( array_key_exists ( 'HEADERS' , $ options ) && is_array ( $ options [ 'HEADERS' ] ) ) { $ this -> setHeaders ( $ options [ 'HEADERS' ] ) ; } // set proper curl options foreach ( $ options as $ key => $ value ) { $ cst_name = 'CURLOPT_' . strtoupper ( trim ( $ key ) ) ; $ cst = defined ( $ cst_name ) ? constant ( $ cst_name ) : null ; if ( $ cst !== null ) { curl_setopt ( $ this -> request , $ cst , $ value ) ; } } }
Sets cURL options and headers for the current request
@param array $options
Sets cURL options and headers for the current request