Я устанавливаю метод cURL, и вопрос, с которым я сталкиваюсь, состоит в том, что если в cURL есть три параметра для установки метода запроса, то как мне удается учитывать каждый из них при каждом вызове?Это похоже на серьезное излишество.
Нужно ли нам быть таким избыточным?См. Каждое утверждение case, изменяющее избыточные опции ниже:
switch ( $method ) {
case 'POST':
curl_setopt( $this->curl, CURLOPT_POST, 1 ); // HTTP POST method
curl_setopt( $this->curl, CURLOPT_HTTPGET, false );
curl_setopt( $this->curl, CURLOPT_CUSTOMREQUEST, null );
break;
case 'GET':
curl_setopt( $this->curl, CURLOPT_POST, 0 ); // HTTP GET method
curl_setopt( $this->curl, CURLOPT_HTTPGET, true );
curl_setopt( $this->curl, CURLOPT_CUSTOMREQUEST, null );
break;
default:
curl_setopt( $this->curl, CURLOPT_POST, 0 ); // HTTP [custom] method
curl_setopt( $this->curl, CURLOPT_HTTPGET, true );
curl_setopt( $this->curl, CURLOPT_CUSTOMREQUEST, $method );
}