Passed
Push — master ( 532413...392df2 )
by Kylian
01:24
created
lib/object/beatmap/BeatMap.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@
 block discarded – undo
180 180
     {
181 181
         $response = [];
182 182
 
183
-        foreach($this->bm->versions as $version) {
183
+        foreach ($this->bm->versions as $version) {
184 184
             $response[] = new BeatMapVersion($version);
185 185
         }
186 186
 
Please login to merge, or discard this patch.
lib/functions/MultiQuery.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         $l_Handles  = [];
35 35
         foreach ($p_URLs as $l_URL)
36 36
         {
37
-            $l_CURL = curl_init($this->apiUrl.$apiUrlExt.$l_URL);
37
+            $l_CURL = curl_init($this->apiUrl . $apiUrlExt . $l_URL);
38 38
             curl_setopt($l_CURL, CURLOPT_USERAGENT, $this->userAgent);
39 39
             curl_setopt($l_CURL, CURLOPT_RETURNTRANSFER, true);
40 40
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
                     mkdir($targetDir, 0777, true);
88 88
                 }
89 89
 
90
-                if(substr($targetDir, -1) !== "/")
90
+                if (substr($targetDir, -1) !== "/")
91 91
                     $targetDir .= "/";
92 92
 
93 93
                 //The path & filename to save to.
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
                 $result = curl_exec($ch);
103 103
 
104
-                if(curl_errno($ch) === 0) {
104
+                if (curl_errno($ch) === 0) {
105 105
                     $response->pushDownloadMapHash($hash);
106 106
                     echo "Ok ";
107 107
                 } else {
Please login to merge, or discard this patch.
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,8 +41,9 @@  discard block
 block discarded – undo
41 41
             $l_Handles[] = $l_CURL;
42 42
         }
43 43
 
44
-        foreach ($l_Handles as $l_Current)
45
-            curl_multi_add_handle($l_Multi, $l_Current);
44
+        foreach ($l_Handles as $l_Current) {
45
+                    curl_multi_add_handle($l_Multi, $l_Current);
46
+        }
46 47
 
47 48
         $l_RunningHandles = null;
48 49
 
@@ -57,10 +58,11 @@  discard block
 block discarded – undo
57 58
         {
58 59
             $l_Error = curl_error($l_Current);
59 60
 
60
-            if (!empty($l_Error) || curl_getinfo($l_Current, CURLINFO_HTTP_CODE) !== 200)
61
-                $l_Result[] = false;
62
-            else
63
-                $l_Result[] = new BeatMap(json_decode(curl_multi_getcontent($l_Current)));
61
+            if (!empty($l_Error) || curl_getinfo($l_Current, CURLINFO_HTTP_CODE) !== 200) {
62
+                            $l_Result[] = false;
63
+            } else {
64
+                            $l_Result[] = new BeatMap(json_decode(curl_multi_getcontent($l_Current)));
65
+            }
64 66
 
65 67
             curl_multi_remove_handle($l_Multi, $l_Current);
66 68
         }
@@ -87,8 +89,9 @@  discard block
 block discarded – undo
87 89
                     mkdir($targetDir, 0777, true);
88 90
                 }
89 91
 
90
-                if(substr($targetDir, -1) !== "/")
91
-                    $targetDir .= "/";
92
+                if(substr($targetDir, -1) !== "/") {
93
+                                    $targetDir .= "/";
94
+                }
92 95
 
93 96
                 //The path & filename to save to.
94 97
                 $saveTo = $targetDir . $hash . $extension;
Please login to merge, or discard this patch.
lib/BeatSaverAPI.php 2 patches
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function __construct(string $userAgent, bool $needAutoloader = false)
25 25
     {
26
-        if($needAutoloader)
26
+        if ($needAutoloader)
27 27
             $this->autoload("./");
28 28
 
29 29
         $this->userAgent = $userAgent;
@@ -31,15 +31,15 @@  discard block
 block discarded – undo
31 31
     }
32 32
 
33 33
     private function autoload($directory) {
34
-        if(is_dir($directory)) {
34
+        if (is_dir($directory)) {
35 35
             $scan = scandir($directory);
36 36
             unset($scan[0], $scan[1]); //unset . and ..
37
-            foreach($scan as $file) {
38
-                if(is_dir($directory."/".$file)) {
39
-                    $this->autoload($directory."/".$file);
37
+            foreach ($scan as $file) {
38
+                if (is_dir($directory . "/" . $file)) {
39
+                    $this->autoload($directory . "/" . $file);
40 40
                 } else {
41
-                    if(strpos($file, '.php') !== false) {
42
-                        include_once($directory."/".$file);
41
+                    if (strpos($file, '.php') !== false) {
42
+                        include_once($directory . "/" . $file);
43 43
                     }
44 44
                 }
45 45
             }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 
84 84
         $apiResult = $this->callAPI($endpoint);
85 85
 
86
-        if($apiResult === false || $apiResult == "Not Found") {
86
+        if ($apiResult === false || $apiResult == "Not Found") {
87 87
             $response->setErrorStatus(true)->setErrorMessage("[getMap] Something went wrong with the API call.");
88 88
             return $response;
89 89
         }
@@ -174,25 +174,25 @@  discard block
 block discarded – undo
174 174
         $maps = [];
175 175
 
176 176
         // Latest
177
-        if($numberOfPage === 0 && $startPage === 0){
177
+        if ($numberOfPage === 0 && $startPage === 0) {
178 178
             $apiResult = json_decode($this->callAPI($endpoint));
179 179
 
180
-            if($apiResult === false || $apiResult == "Not Found") {
180
+            if ($apiResult === false || $apiResult == "Not Found") {
181 181
                 $response->setErrorStatus(true)->setErrorMessage("[getMaps] Something went wrong with the API call while calling the first page.");
182 182
                 return $response;
183
-            } else{
183
+            } else {
184 184
                 foreach ($apiResult->docs as $beatmap) {
185 185
                     $maps[] = new BeatMap($beatmap);
186 186
                 }
187 187
             }
188 188
         } else {
189
-            for($i = $startPage; $i < ($i + $numberOfPage); $i++){
189
+            for ($i = $startPage; $i < ($i + $numberOfPage); $i++) {
190 190
                 $apiResult = json_decode($this->callAPI(str_ireplace("page", $i, $endpoint)));
191 191
 
192
-                if($apiResult === false || $apiResult == "Not Found") {
192
+                if ($apiResult === false || $apiResult == "Not Found") {
193 193
                     $response->setErrorStatus(true)->setErrorMessage("[getMaps] Something went wrong with the API call while calling page number " . $i . ".");
194 194
 
195
-                    if($apiResult == "Not Found")
195
+                    if ($apiResult == "Not Found")
196 196
                         return $response;
197 197
                 }
198 198
 
@@ -274,23 +274,23 @@  discard block
 block discarded – undo
274 274
 
275 275
         $endpoint = "/search/text/page?sortOrder=" . $sort[$sortOrder];
276 276
 
277
-        if($mapName)                $endpoint .= "&q=" . urlencode($mapName);
278
-        if($startDate)              $endpoint .= "&from=" . $startDate->format("Y-m-d");
279
-        if($endDate)                $endpoint .= "&to=" . $endDate->format("Y-m-d");
280
-        if($ranked)                 $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true);
281
-        if($automapper)             $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true);
282
-        if($chroma)                 $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true);
283
-        if($noodle)                 $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true);
284
-        if($cinema)                 $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true);
285
-        if($fullSpread)             $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true);
286
-        if($minBpm)                 $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm;
287
-        if($maxBpm)                 $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm;
288
-        if($minNps)                 $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps;
289
-        if($maxNps)                 $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps;
290
-        if($minRating)              $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating;
291
-        if($maxRating)              $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating;
292
-        if($minDuration !== null)   $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration;
293
-        if($maxDuration !== null)   $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration;
277
+        if ($mapName)                $endpoint .= "&q=" . urlencode($mapName);
278
+        if ($startDate)              $endpoint .= "&from=" . $startDate->format("Y-m-d");
279
+        if ($endDate)                $endpoint .= "&to=" . $endDate->format("Y-m-d");
280
+        if ($ranked)                 $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true);
281
+        if ($automapper)             $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true);
282
+        if ($chroma)                 $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true);
283
+        if ($noodle)                 $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true);
284
+        if ($cinema)                 $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true);
285
+        if ($fullSpread)             $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true);
286
+        if ($minBpm)                 $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm;
287
+        if ($maxBpm)                 $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm;
288
+        if ($minNps)                 $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps;
289
+        if ($maxNps)                 $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps;
290
+        if ($minRating)              $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating;
291
+        if ($maxRating)              $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating;
292
+        if ($minDuration !== null)   $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration;
293
+        if ($maxDuration !== null)   $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration;
294 294
 
295 295
         return $this->getMapsByEndpoint($endpoint, $numberOfPage, $startPage);
296 296
     }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 
311 311
         $apiResult = $this->callAPI($endpoint);
312 312
 
313
-        if($apiResult === false || $apiResult == "Not Found") {
313
+        if ($apiResult === false || $apiResult == "Not Found") {
314 314
             $response->setErrorStatus(true)->setErrorMessage("[getMap] Something went wrong with the API call.");
315 315
             return $response;
316 316
         }
Please login to merge, or discard this patch.
Braces   +57 added lines, -21 removed lines patch added patch discarded remove patch
@@ -23,8 +23,9 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function __construct(string $userAgent, bool $needAutoloader = false)
25 25
     {
26
-        if($needAutoloader)
27
-            $this->autoload("./");
26
+        if($needAutoloader) {
27
+                    $this->autoload("./");
28
+        }
28 29
 
29 30
         $this->userAgent = $userAgent;
30 31
         $this->multiQuery = new MultiQuery(self::BEATSAVER_URL, $userAgent);
@@ -192,8 +193,9 @@  discard block
 block discarded – undo
192 193
                 if($apiResult === false || $apiResult == "Not Found") {
193 194
                     $response->setErrorStatus(true)->setErrorMessage("[getMaps] Something went wrong with the API call while calling page number " . $i . ".");
194 195
 
195
-                    if($apiResult == "Not Found")
196
-                        return $response;
196
+                    if($apiResult == "Not Found") {
197
+                                            return $response;
198
+                    }
197 199
                 }
198 200
 
199 201
                 foreach ($apiResult->docs as $beatmap) {
@@ -274,23 +276,57 @@  discard block
 block discarded – undo
274 276
 
275 277
         $endpoint = "/search/text/page?sortOrder=" . $sort[$sortOrder];
276 278
 
277
-        if($mapName)                $endpoint .= "&q=" . urlencode($mapName);
278
-        if($startDate)              $endpoint .= "&from=" . $startDate->format("Y-m-d");
279
-        if($endDate)                $endpoint .= "&to=" . $endDate->format("Y-m-d");
280
-        if($ranked)                 $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true);
281
-        if($automapper)             $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true);
282
-        if($chroma)                 $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true);
283
-        if($noodle)                 $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true);
284
-        if($cinema)                 $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true);
285
-        if($fullSpread)             $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true);
286
-        if($minBpm)                 $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm;
287
-        if($maxBpm)                 $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm;
288
-        if($minNps)                 $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps;
289
-        if($maxNps)                 $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps;
290
-        if($minRating)              $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating;
291
-        if($maxRating)              $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating;
292
-        if($minDuration !== null)   $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration;
293
-        if($maxDuration !== null)   $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration;
279
+        if($mapName) {
280
+            $endpoint .= "&q=" . urlencode($mapName);
281
+        }
282
+        if($startDate) {
283
+            $endpoint .= "&from=" . $startDate->format("Y-m-d");
284
+        }
285
+        if($endDate) {
286
+            $endpoint .= "&to=" . $endDate->format("Y-m-d");
287
+        }
288
+        if($ranked) {
289
+            $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true);
290
+        }
291
+        if($automapper) {
292
+            $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true);
293
+        }
294
+        if($chroma) {
295
+            $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true);
296
+        }
297
+        if($noodle) {
298
+            $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true);
299
+        }
300
+        if($cinema) {
301
+            $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true);
302
+        }
303
+        if($fullSpread) {
304
+            $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true);
305
+        }
306
+        if($minBpm) {
307
+            $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm;
308
+        }
309
+        if($maxBpm) {
310
+            $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm;
311
+        }
312
+        if($minNps) {
313
+            $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps;
314
+        }
315
+        if($maxNps) {
316
+            $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps;
317
+        }
318
+        if($minRating) {
319
+            $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating;
320
+        }
321
+        if($maxRating) {
322
+            $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating;
323
+        }
324
+        if($minDuration !== null) {
325
+            $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration;
326
+        }
327
+        if($maxDuration !== null) {
328
+            $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration;
329
+        }
294 330
 
295 331
         return $this->getMapsByEndpoint($endpoint, $numberOfPage, $startPage);
296 332
     }
Please login to merge, or discard this patch.