Passed
Push — main ( fd90d3...b4e90b )
by Dylan
02:22
created
tests/UtilsTest.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,9 @@
 block discarded – undo
68 68
 
69 69
         // Test the randomness
70 70
         $generated = [];
71
-        while (count($generated) < 100000) $generated[] = Utils::create_random_string();
71
+        while (count($generated) < 100000) {
72
+            $generated[] = Utils::create_random_string();
73
+        }
72 74
         $count  = count($generated);
73 75
         $unique = count(array_unique($generated));
74 76
         $random = 100 - ((100 / $count) * $unique);
Please login to merge, or discard this patch.
src/utils/Curl.php 1 patch
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,8 +40,12 @@  discard block
 block discarded – undo
40 40
     public function __construct(string $url, array $data = [], array $headers = [])
41 41
     {
42 42
         $this->setURL($url);
43
-        foreach ($data as $name => $value)      $this->addDataParam($name, $value);
44
-        foreach ($headers as $name => $value)   $this->addHeader($name, $value);
43
+        foreach ($data as $name => $value) {
44
+            $this->addDataParam($name, $value);
45
+        }
46
+        foreach ($headers as $name => $value) {
47
+            $this->addHeader($name, $value);
48
+        }
45 49
     }
46 50
 
47 51
     /**
@@ -98,7 +102,9 @@  discard block
 block discarded – undo
98 102
 
99 103
     public function removeDataParam(string $name): Curl
100 104
     {
101
-        if (array_key_exists($name, $this->_data)) unset($this->_data[$name]);
105
+        if (array_key_exists($name, $this->_data)) {
106
+            unset($this->_data[$name]);
107
+        }
102 108
         return $this;
103 109
     }
104 110
 
@@ -127,7 +133,9 @@  discard block
 block discarded – undo
127 133
      */
128 134
     public function removeHeader(string $name): Curl
129 135
     {
130
-        if (array_key_exists($name, $this->_headers)) unset($this->_headers[$name]);
136
+        if (array_key_exists($name, $this->_headers)) {
137
+            unset($this->_headers[$name]);
138
+        }
131 139
         return $this;
132 140
     }
133 141
 
@@ -171,13 +179,17 @@  discard block
 block discarded – undo
171 179
         $request_uri    = $this->getURL();
172 180
 
173 181
         //  Headers
174
-        foreach ($this->getHeaders() as $k => $v) $send_headers[] = "{$k}: {$v}";
182
+        foreach ($this->getHeaders() as $k => $v) {
183
+            $send_headers[] = "{$k}: {$v}";
184
+        }
175 185
 
176 186
         // Request Data
177 187
         switch ($this->getMethod()) {
178 188
             case 'GET':
179 189
             case 'DELETE':
180
-                foreach ($this->getDataParams() as $name => $value) $request_uri = URL::setGetVar($name, $value, $request_uri);
190
+                foreach ($this->getDataParams() as $name => $value) {
191
+                    $request_uri = URL::setGetVar($name, $value, $request_uri);
192
+                }
181 193
                 break;
182 194
 
183 195
             case 'POST':
@@ -208,7 +220,9 @@  discard block
 block discarded – undo
208 220
         curl_setopt($ch, CURLINFO_HEADER_OUT, true);
209 221
         curl_setopt($ch, CURLOPT_AUTOREFERER, true);
210 222
 
211
-        if (!empty($send_headers))  curl_setopt($ch, CURLOPT_HTTPHEADER, $send_headers);
223
+        if (!empty($send_headers)) {
224
+            curl_setopt($ch, CURLOPT_HTTPHEADER, $send_headers);
225
+        }
212 226
         if (!is_null($post_data))   {
213 227
             curl_setopt($ch, CURLOPT_POST, 1);
214 228
             curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
@@ -218,7 +232,9 @@  discard block
 block discarded – undo
218 232
         $http_code  = curl_getinfo($ch, CURLINFO_HTTP_CODE);
219 233
 
220 234
         $response = new CurlResponse($http_code, $result);
221
-        if ($this->_enable_cache && isset($cache_key)) self::$_cache[$cache_key] = $response;
235
+        if ($this->_enable_cache && isset($cache_key)) {
236
+            self::$_cache[$cache_key] = $response;
237
+        }
222 238
 
223 239
         return $response;
224 240
     }
Please login to merge, or discard this patch.