Passed
Push — master ( e75eb9...7e27c3 )
by Kylian
01:24
created
lib/BeatSaverAPI.php 1 patch
Braces   +60 added lines, -23 removed lines patch added patch discarded remove patch
@@ -116,13 +116,15 @@  discard block
 block discarded – undo
116 116
             if($apiResult === false || $apiResult == "Not Found") {
117 117
                 $response["error"] = true;
118 118
 
119
-                if($apiResult == "Not Found")
120
-                    break;
119
+                if($apiResult == "Not Found") {
120
+                                    break;
121
+                }
121 122
             } else {
122 123
                 $apiResult = json_decode($apiResult, true);
123 124
 
124
-                if(count($apiResult["docs"]) === 0)
125
-                    break;
125
+                if(count($apiResult["docs"]) === 0) {
126
+                                    break;
127
+                }
126 128
 
127 129
                 if(($page + 1) * self::MAPS_NUMBERS_PER_PAGE <= $limit) {
128 130
                     $response["maps"] = array_merge($response["maps"], $apiResult["docs"]);
@@ -135,8 +137,9 @@  discard block
 block discarded – undo
135 137
                 }
136 138
             }
137 139
 
138
-            if(count($apiResult["docs"]) < ($page + 1) * self::MAPS_NUMBERS_PER_PAGE)
139
-                break;
140
+            if(count($apiResult["docs"]) < ($page + 1) * self::MAPS_NUMBERS_PER_PAGE) {
141
+                            break;
142
+            }
140 143
         }
141 144
 
142 145
         return $response;
@@ -206,23 +209,57 @@  discard block
 block discarded – undo
206 209
 
207 210
         $endpoint = "/search/text/page?sortOrder=" . $sort[$sortOrder];
208 211
 
209
-        if($mapName)        $endpoint .= "&q=" . urlencode($mapName);
210
-        if($startDate)      $endpoint .= "&from=" . $startDate->format("Y-m-d");
211
-        if($endDate)        $endpoint .= "&to=" . $endDate->format("Y-m-d");
212
-        if($ranked)         $endpoint .= "&ranked=" . $ranked;
213
-        if($automapper)     $endpoint .= "&automapper=" . $automapper;
214
-        if($chroma)         $endpoint .= "&chroma=" . $chroma;
215
-        if($noodle)         $endpoint .= "&noodle=" . $noodle;
216
-        if($cinema)         $endpoint .= "&cinema=" . $cinema;
217
-        if($fullSpread)     $endpoint .= "&fullSpread=" . $fullSpread;
218
-        if($minBpm)         $endpoint .= "&minBpm=" . $minBpm;
219
-        if($maxBpm)         $endpoint .= "&maxBpm=" . $maxBpm;
220
-        if($minNps)         $endpoint .= "&minNps=" . $minNps;
221
-        if($maxNps)         $endpoint .= "&maxNps=" . $maxNps;
222
-        if($minRating)      $endpoint .= "&minRating=" . $minRating;
223
-        if($maxRating)      $endpoint .= "&maxRating=" . $maxRating;
224
-        if($minDuration)    $endpoint .= "&minDuration=" . $minDuration;
225
-        if($maxDuration)    $endpoint .= "&maxDuration=" . $maxDuration;
212
+        if($mapName) {
213
+            $endpoint .= "&q=" . urlencode($mapName);
214
+        }
215
+        if($startDate) {
216
+            $endpoint .= "&from=" . $startDate->format("Y-m-d");
217
+        }
218
+        if($endDate) {
219
+            $endpoint .= "&to=" . $endDate->format("Y-m-d");
220
+        }
221
+        if($ranked) {
222
+            $endpoint .= "&ranked=" . $ranked;
223
+        }
224
+        if($automapper) {
225
+            $endpoint .= "&automapper=" . $automapper;
226
+        }
227
+        if($chroma) {
228
+            $endpoint .= "&chroma=" . $chroma;
229
+        }
230
+        if($noodle) {
231
+            $endpoint .= "&noodle=" . $noodle;
232
+        }
233
+        if($cinema) {
234
+            $endpoint .= "&cinema=" . $cinema;
235
+        }
236
+        if($fullSpread) {
237
+            $endpoint .= "&fullSpread=" . $fullSpread;
238
+        }
239
+        if($minBpm) {
240
+            $endpoint .= "&minBpm=" . $minBpm;
241
+        }
242
+        if($maxBpm) {
243
+            $endpoint .= "&maxBpm=" . $maxBpm;
244
+        }
245
+        if($minNps) {
246
+            $endpoint .= "&minNps=" . $minNps;
247
+        }
248
+        if($maxNps) {
249
+            $endpoint .= "&maxNps=" . $maxNps;
250
+        }
251
+        if($minRating) {
252
+            $endpoint .= "&minRating=" . $minRating;
253
+        }
254
+        if($maxRating) {
255
+            $endpoint .= "&maxRating=" . $maxRating;
256
+        }
257
+        if($minDuration) {
258
+            $endpoint .= "&minDuration=" . $minDuration;
259
+        }
260
+        if($maxDuration) {
261
+            $endpoint .= "&maxDuration=" . $maxDuration;
262
+        }
226 263
 
227 264
         return $this->getMaps($endpoint, $limit);
228 265
     }
Please login to merge, or discard this patch.