Passed
Push — master ( d16243...311ea7 )
by Shahrad
01:34
created
src/lib/Util/Utils.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -69,11 +69,15 @@
 block discarded – undo
69 69
     {
70 70
         if ($binaryPrefix) {
71 71
             $unit = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB');
72
-            if ($bytes == 0) return '0 ' . $unit[0];
72
+            if ($bytes == 0) {
73
+                return '0 ' . $unit[0];
74
+            }
73 75
             return @round($bytes / pow(1024, ($i = floor(log($bytes, 1024)))), 2) . ' ' . ($unit[$i] ?? 'B');
74 76
         } else {
75 77
             $unit = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
76
-            if ($bytes == 0) return '0 ' . $unit[0];
78
+            if ($bytes == 0) {
79
+                return '0 ' . $unit[0];
80
+            }
77 81
             return @round($bytes / pow(1000, ($i = floor(log($bytes, 1000)))), 2) . ' ' . ($unit[$i] ?? 'B');
78 82
         }
79 83
     }
Please login to merge, or discard this patch.
examples/download-large-file.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,14 +7,18 @@
 block discarded – undo
7 7
 
8 8
 $client = new \EasyHttp\Client();
9 9
 
10
-if (!file_exists(__DIR__ . '/tmp')) mkdir(__DIR__ . '/tmp');
10
+if (!file_exists(__DIR__ . '/tmp')) {
11
+    mkdir(__DIR__ . '/tmp');
12
+}
11 13
 $client->setTempPath(__DIR__ . '/tmp');
12 14
 
13 15
 $Result = $client->download($DirectLink);
14 16
 
15 17
 echo '<pre>' . json_encode($Result->downloads, JSON_PRETTY_PRINT) . '</pre>';
16 18
 
17
-if (!file_exists(__DIR__ . '/uploads')) mkdir(__DIR__ . '/uploads');
19
+if (!file_exists(__DIR__ . '/uploads')) {
20
+    mkdir(__DIR__ . '/uploads');
21
+}
18 22
 
19 23
 if ($Result->save(__DIR__ . '/uploads/google.png')) {
20 24
     echo 'File saved successfully';
Please login to merge, or discard this patch.
src/lib/Model/HttpResponse.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,9 @@
 block discarded – undo
90 90
      */
91 91
     public function getCurlInfo(): CurlInfo|false
92 92
     {
93
-        if (empty($this->curlHandle)) return false;
93
+        if (empty($this->curlHandle)) {
94
+            return false;
95
+        }
94 96
         return new CurlInfo(curl_getinfo($this->curlHandle));
95 97
     }
96 98
 
Please login to merge, or discard this patch.
src/lib/Model/DownloadResult.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -132,7 +132,9 @@
 block discarded – undo
132 132
     public function save(string $filePath): bool
133 133
     {
134 134
         $pathInfo = pathinfo($filePath, PATHINFO_DIRNAME);
135
-        if (gettype($pathInfo) != "string") $pathInfo = $pathInfo['dirname'];
135
+        if (gettype($pathInfo) != "string") {
136
+            $pathInfo = $pathInfo['dirname'];
137
+        }
136 138
         if (!file_exists($pathInfo)) {
137 139
             throw new \InvalidArgumentException('The directory does not exist');
138 140
         }
Please login to merge, or discard this patch.
src/lib/Client.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 
109 109
         $result->setStatusCode(curl_getinfo($CurlHandle, CURLINFO_HTTP_CODE));
110 110
         $result->setHeaderSize(curl_getinfo($CurlHandle, CURLINFO_HEADER_SIZE));
111
-        $result->setHeaders(substr((string)$response, 0, $result->getHeaderSize()));
112
-        $result->setBody(substr((string)$response, $result->getHeaderSize()));
111
+        $result->setHeaders(substr((string) $response, 0, $result->getHeaderSize()));
112
+        $result->setBody(substr((string) $response, $result->getHeaderSize()));
113 113
 
114 114
         curl_close($CurlHandle);
115 115
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
             ]
430 430
         ]);
431 431
 
432
-        return (int)$response->getHeaderLine('Content-Length') ?? 0;
432
+        return (int) $response->getHeaderLine('Content-Length') ?? 0;
433 433
     }
434 434
 
435 435
     /**
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -94,7 +94,9 @@  discard block
 block discarded – undo
94 94
     public function request(string $method, string $uri, array|HttpOptions $options = []): HttpResponse
95 95
     {
96 96
         $CurlHandle = $this->createCurlHandler($method, $uri, $options);
97
-        if (!$CurlHandle) throw new \RuntimeException('Curl handle has not been created');
97
+        if (!$CurlHandle) {
98
+            throw new \RuntimeException('Curl handle has not been created');
99
+        }
98 100
 
99 101
         $result = new HttpResponse();
100 102
         $result->setCurlHandle($CurlHandle);
@@ -135,7 +137,9 @@  discard block
 block discarded – undo
135 137
                 $request['uri'],
136 138
                 $request['options'] ?? []
137 139
             );
138
-            if (!$CurlHandle) throw new \RuntimeException('Curl handle has not been created');
140
+            if (!$CurlHandle) {
141
+                throw new \RuntimeException('Curl handle has not been created');
142
+            }
139 143
             $handlers[] = $CurlHandle;
140 144
             curl_multi_add_handle($multi_handler, $CurlHandle);
141 145
 
@@ -192,14 +196,18 @@  discard block
 block discarded – undo
192 196
     private function createCurlHandler(?string $method, string $uri, array|HttpOptions $options = []): false|CurlHandle
193 197
     {
194 198
         $handler = curl_init();
195
-        if (is_resource($handler) || !$handler) return false;
199
+        if (is_resource($handler) || !$handler) {
200
+            return false;
201
+        }
196 202
 
197 203
         if (gettype($options) === 'array') {
198 204
             $options = new HttpOptions($options);
199 205
         }
200 206
 
201 207
         if (count($options->queries) > 0) {
202
-            if (!str_contains($uri, '?')) $uri .= '?';
208
+            if (!str_contains($uri, '?')) {
209
+                $uri .= '?';
210
+            }
203 211
             $uri .= $options->getQueryString();
204 212
         }
205 213
 
Please login to merge, or discard this patch.