Passed
Pull Request — master (#1)
by Kylian
07:28 queued 05:58
created
lib/BeatSaverAPI.php 1 patch
Braces   +63 added lines, -25 removed lines patch added patch discarded remove patch
@@ -25,8 +25,9 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function __construct(string $userAgent, bool $needAutoloader = false)
27 27
     {
28
-        if($needAutoloader)
29
-            $this->autoload("./");
28
+        if($needAutoloader) {
29
+                    $this->autoload("./");
30
+        }
30 31
 
31 32
         $this->userAgent = $userAgent;
32 33
     }
@@ -231,8 +232,9 @@  discard block
 block discarded – undo
231 232
             }
232 233
         }
233 234
 
234
-        if(isset($mapsArray["errorStatus"]) && $mapsArray["errorStatus"])
235
-            $result->setErrorStatus( $mapsArray["errorStatus"])->setErrorMessage( $mapsArray["errorMessage"]);
235
+        if(isset($mapsArray["errorStatus"]) && $mapsArray["errorStatus"]) {
236
+                    $result->setErrorStatus( $mapsArray["errorStatus"])->setErrorMessage( $mapsArray["errorMessage"]);
237
+        }
236 238
 
237 239
         unset($mapsArray["errorStatus"]);
238 240
         unset($mapsArray["errorMessage"]);
@@ -278,8 +280,9 @@  discard block
 block discarded – undo
278 280
                 if($apiResult === false || $apiResult == "Not Found") {
279 281
                     $response->setErrorStatus(true)->setErrorMessage("[getMaps] Something went wrong with the API call while calling page number " . $i . ".");
280 282
 
281
-                    if($apiResult == "Not Found")
282
-                        return $response;
283
+                    if($apiResult == "Not Found") {
284
+                                            return $response;
285
+                    }
283 286
                 }
284 287
 
285 288
                 foreach ($apiResult->docs as $beatmap) {
@@ -360,23 +363,57 @@  discard block
 block discarded – undo
360 363
 
361 364
         $endpoint = "/search/text/page?sortOrder=" . $sort[$sortOrder];
362 365
 
363
-        if($mapName)                $endpoint .= "&q=" . urlencode($mapName);
364
-        if($startDate)              $endpoint .= "&from=" . $startDate->format("Y-m-d");
365
-        if($endDate)                $endpoint .= "&to=" . $endDate->format("Y-m-d");
366
-        if($ranked)                 $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true);
367
-        if($automapper)             $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true);
368
-        if($chroma)                 $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true);
369
-        if($noodle)                 $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true);
370
-        if($cinema)                 $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true);
371
-        if($fullSpread)             $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true);
372
-        if($minBpm)                 $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm;
373
-        if($maxBpm)                 $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm;
374
-        if($minNps)                 $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps;
375
-        if($maxNps)                 $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps;
376
-        if($minRating)              $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating;
377
-        if($maxRating)              $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating;
378
-        if($minDuration !== null)   $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration;
379
-        if($maxDuration !== null)   $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration;
366
+        if($mapName) {
367
+            $endpoint .= "&q=" . urlencode($mapName);
368
+        }
369
+        if($startDate) {
370
+            $endpoint .= "&from=" . $startDate->format("Y-m-d");
371
+        }
372
+        if($endDate) {
373
+            $endpoint .= "&to=" . $endDate->format("Y-m-d");
374
+        }
375
+        if($ranked) {
376
+            $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true);
377
+        }
378
+        if($automapper) {
379
+            $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true);
380
+        }
381
+        if($chroma) {
382
+            $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true);
383
+        }
384
+        if($noodle) {
385
+            $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true);
386
+        }
387
+        if($cinema) {
388
+            $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true);
389
+        }
390
+        if($fullSpread) {
391
+            $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true);
392
+        }
393
+        if($minBpm) {
394
+            $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm;
395
+        }
396
+        if($maxBpm) {
397
+            $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm;
398
+        }
399
+        if($minNps) {
400
+            $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps;
401
+        }
402
+        if($maxNps) {
403
+            $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps;
404
+        }
405
+        if($minRating) {
406
+            $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating;
407
+        }
408
+        if($maxRating) {
409
+            $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating;
410
+        }
411
+        if($minDuration !== null) {
412
+            $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration;
413
+        }
414
+        if($maxDuration !== null) {
415
+            $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration;
416
+        }
380 417
 
381 418
         return $this->getMapsByEndpoint($endpoint, $numberOfPage, $startPage);
382 419
     }
@@ -428,8 +465,9 @@  discard block
 block discarded – undo
428 465
             mkdir($targetDir, 0777, true);
429 466
         }
430 467
 
431
-        if(substr($targetDir, -1) !== "/")
432
-            $targetDir .= "/";
468
+        if(substr($targetDir, -1) !== "/") {
469
+                    $targetDir .= "/";
470
+        }
433 471
 
434 472
         foreach ($hashes as $hash) {
435 473
             //The path & filename to save to.
Please login to merge, or discard this patch.