public function execute() {
        $ch = \curl_init();

        $this->setAuth($ch);
        try {
            switch (strtoupper($this->method)) {
                case 'GET':
                    $this->executeGet($ch);
                    break;
                case 'POST':
                    $this->executePost($ch);
                    break;
                case 'PUT':
                    $this->executePut($ch);
                    break;
                case 'PATCH':
                    $this->executePatch($ch);
                    break;
                case 'DELETE':
                    $this->executeDelete($ch);
                    break;
                // This custom case is used to execute a Multipart PUT request
                case 'PUT_MP':
                    $this->method = 'PUT';
                    $this->executePutMultipart($ch);
                    break;
                case 'POST_MP':
                    $this->method = 'POST';
                    $this->executePostMultipart($ch);
                    break;
                default:
                    throw new \InvalidArgumentException('Current method (' . $this->method . ') is an invalid REST method.');
            }
        } catch (\InvalidArgumentException $e) {
            \curl_close($ch);
            throw $e;
        } catch (\Exception $e) {
            \curl_close($ch);
            throw $e;
        }
    }
public function execute() {
        $ch = \curl_init();

        $this->setAuth($ch);
        try {
            switch (strtoupper($this->method)) {
                case 'GET':
                    $this->executeGet($ch);
                    break;
                case 'POST':
                    $this->executePost($ch);
                    break;
                case 'PUT':
                    $this->executePut($ch);
                    break;
                case 'PATCH':
                    $this->executePatch($ch);
                    break;
                case 'DELETE':
                    $this->executeDelete($ch);
                    break;
                // This custom case is used to execute a Multipart PUT request
                case 'PUT_MP':
                    $this->method = 'PUT';
                    $this->executePutMultipart($ch);
                    break;
                case 'POST_MP':
                    $this->method = 'POST';
                    $this->executePostMultipart($ch);
                    break;
                default:
                    throw new \InvalidArgumentException('Current method (' . $this->method . ') is an invalid REST method.');
            }
        } catch (\InvalidArgumentException $e) {
            \curl_close($ch);
            throw $e;
        } catch (\Exception $e) {
            \curl_close($ch);
            throw $e;
        }
    }
public function execute ( ) { $ ch = \ curl_init ( ) ; $ this -> setAuth ( $ ch ) ; try { switch ( strtoupper ( $ this -> method ) ) { case 'GET' : $ this -> executeGet ( $ ch ) ; break ; case 'POST' : $ this -> executePost ( $ ch ) ; break ; case 'PUT' : $ this -> executePut ( $ ch ) ; break ; case 'PATCH' : $ this -> executePatch ( $ ch ) ; break ; case 'DELETE' : $ this -> executeDelete ( $ ch ) ; break ; // This custom case is used to execute a Multipart PUT request case 'PUT_MP' : $ this -> method = 'PUT' ; $ this -> executePutMultipart ( $ ch ) ; break ; case 'POST_MP' : $ this -> method = 'POST' ; $ this -> executePostMultipart ( $ ch ) ; break ; default : throw new \ InvalidArgumentException ( 'Current method (' . $ this -> method . ') is an invalid REST method.' ) ; } } catch ( \ InvalidArgumentException $ e ) { \ curl_close ( $ ch ) ; throw $ e ; } catch ( \ Exception $ e ) { \ curl_close ( $ ch ) ; throw $ e ; } }
Execute curl request for each type of HTTP Request

@throws \InvalidArgumentException
Execute curl request for each type of HTTP Request