private function processMethod($method, array $options, array $headers, array $body = [])
    {
        if ($method === 'get') {
            if ($body !== []) {
                throw new \Exception('Issuing a GET request with a body');
            }
            $options[CURLOPT_HTTPGET] = 1;
        } elseif ($method === 'post') {
            $data_string = json_encode($body);

            $options[CURLOPT_POST] = 1;
            $options[CURLOPT_POSTFIELDS] = $data_string;

            array_push($headers, 'Content-Type: application/json');
            array_push($headers, 'Content-Length: ' . strlen($data_string));
        } else {
            throw new \Exception('Unrecognized method ' . strtoupper($method));
        }

        return [$options, $headers];
    }
private function processMethod($method, array $options, array $headers, array $body = [])
    {
        if ($method === 'get') {
            if ($body !== []) {
                throw new \Exception('Issuing a GET request with a body');
            }
            $options[CURLOPT_HTTPGET] = 1;
        } elseif ($method === 'post') {
            $data_string = json_encode($body);

            $options[CURLOPT_POST] = 1;
            $options[CURLOPT_POSTFIELDS] = $data_string;

            array_push($headers, 'Content-Type: application/json');
            array_push($headers, 'Content-Length: ' . strlen($data_string));
        } else {
            throw new \Exception('Unrecognized method ' . strtoupper($method));
        }

        return [$options, $headers];
    }
private function processMethod ( $ method , array $ options , array $ headers , array $ body = [ ] ) { if ( $ method === 'get' ) { if ( $ body !== [ ] ) { throw new \ Exception ( 'Issuing a GET request with a body' ) ; } $ options [ CURLOPT_HTTPGET ] = 1 ; } elseif ( $ method === 'post' ) { $ data_string = json_encode ( $ body ) ; $ options [ CURLOPT_POST ] = 1 ; $ options [ CURLOPT_POSTFIELDS ] = $ data_string ; array_push ( $ headers , 'Content-Type: application/json' ) ; array_push ( $ headers , 'Content-Length: ' . strlen ( $ data_string ) ) ; } else { throw new \ Exception ( 'Unrecognized method ' . strtoupper ( $ method ) ) ; } return [ $ options , $ headers ] ; }
Setup behavior for each methods
@param string $method
@param array $options
@param array $headers
@param array $body
@return [$options, $headers]
@throws \Exception
Setup behavior for each methods