Passed
Push — master ( efb646...c2efff )
by Filippo
02:37
created
src/Surfer/Adapter/CurlAdapter.php 1 patch
Braces   +15 added lines, -12 removed lines patch added patch discarded remove patch
@@ -55,8 +55,9 @@  discard block
 block discarded – undo
55 55
    * @copydoc AbstractAdapter::initialize()
56 56
    */
57 57
   public function initialize() {
58
-    if (!extension_loaded("curl"))
59
-      throw new \RuntimeException("The cURL extension is not loaded.");
58
+    if (!extension_loaded("curl")) {
59
+          throw new \RuntimeException("The cURL extension is not loaded.");
60
+    }
60 61
   }
61 62
 
62 63
 
@@ -76,8 +77,9 @@  discard block
 block discarded – undo
76 77
     $opts = [];
77 78
 
78 79
     // Resets all the cURL options. The curl_reset() function is available only since PHP 5.5.
79
-    if (function_exists('curl_reset'))
80
-      curl_reset($this->handle);
80
+    if (function_exists('curl_reset')) {
81
+          curl_reset($this->handle);
82
+    }
81 83
 
82 84
     // Sets the methods and its related options.
83 85
     switch ($request->getMethod()) {
@@ -112,9 +114,9 @@  discard block
 block discarded – undo
112 114
 
113 115
             $opts[CURLOPT_INFILE] = $fd;
114 116
             $opts[CURLOPT_INFILESIZE] = $request->getBodyLength();
117
+          } else {
118
+                      throw new \RuntimeException("Cannot create the stream.");
115 119
           }
116
-          else
117
-            throw new \RuntimeException("Cannot create the stream.");
118 120
         }
119 121
 
120 122
         break;
@@ -155,8 +157,9 @@  discard block
 block discarded – undo
155 157
     // This fix a known cURL bug: see http://the-stickman.com/web-development/php-and-curl-disabling-100-continue-header/
156 158
     // cURL sets the Expect header field automatically, ignoring the fact that a client may not need it for the specific
157 159
     // request.
158
-    if (!$request->hasHeaderField(Request::EXPECT_HF))
159
-      curl_setopt($this->handle, CURLOPT_HTTPHEADER, array("Expect:"));
160
+    if (!$request->hasHeaderField(Request::EXPECT_HF)) {
161
+          curl_setopt($this->handle, CURLOPT_HTTPHEADER, array("Expect:"));
162
+    }
160 163
 
161 164
     // Sets the request header.
162 165
     // Due to a stupid bug, using curl_setopt_array(), cURL doesn't override the Content-Type header field. So we must
@@ -184,15 +187,15 @@  discard block
 block discarded – undo
184 187
         });
185 188
     }
186 189
 
187
-    if ($this->timeout)
188
-      curl_setopt($this->handle, CURLOPT_TIMEOUT, $this->timeout);
190
+    if ($this->timeout) {
191
+          curl_setopt($this->handle, CURLOPT_TIMEOUT, $this->timeout);
192
+    }
189 193
 
190 194
     if ($result = curl_exec($this->handle)) {
191 195
       $response = new Response($header);
192 196
       $response->setBody($result);
193 197
       return $response;
194
-    }
195
-    else {
198
+    } else {
196 199
       $error = curl_error($this->handle);
197 200
       throw new \RuntimeException($error);
198 201
     }
Please login to merge, or discard this patch.