Passed
Push — master ( eba474...e75eb9 )
by Kylian
01:49 queued 12s
created
lib/BeatSaverAPI.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -110,32 +110,32 @@  discard block
 block discarded – undo
110 110
             "maps" => []
111 111
         ];
112 112
 
113
-        for($page = 0; $page <= floor(($limit - 1) / self::MAPS_NUMBERS_PER_PAGE); $page++) {
113
+        for ($page = 0; $page <= floor(($limit - 1) / self::MAPS_NUMBERS_PER_PAGE); $page++) {
114 114
             $apiResult = $this->callAPI(str_ireplace("page", $page, $endpoint));
115 115
 
116
-            if($apiResult === false || $apiResult == "Not Found") {
116
+            if ($apiResult === false || $apiResult == "Not Found") {
117 117
                 $response["error"] = true;
118 118
 
119
-                if($apiResult == "Not Found")
119
+                if ($apiResult == "Not Found")
120 120
                     break;
121 121
             } else {
122 122
                 $apiResult = json_decode($apiResult, true);
123 123
 
124
-                if(count($apiResult["docs"]) === 0)
124
+                if (count($apiResult["docs"]) === 0)
125 125
                     break;
126 126
 
127
-                if(($page + 1) * self::MAPS_NUMBERS_PER_PAGE <= $limit) {
127
+                if (($page + 1) * self::MAPS_NUMBERS_PER_PAGE <= $limit) {
128 128
                     $response["maps"] = array_merge($response["maps"], $apiResult["docs"]);
129 129
                 } else {
130 130
                     $max = $limit <= self::MAPS_NUMBERS_PER_PAGE ? $limit : $limit - ($page * self::MAPS_NUMBERS_PER_PAGE);
131 131
 
132
-                    for($i = 0; $i < $max; $i++) {
132
+                    for ($i = 0; $i < $max; $i++) {
133 133
                         array_push($response["maps"], $apiResult["docs"][$i]);
134 134
                     }
135 135
                 }
136 136
             }
137 137
 
138
-            if(count($apiResult["docs"]) < ($page + 1) * self::MAPS_NUMBERS_PER_PAGE)
138
+            if (count($apiResult["docs"]) < ($page + 1) * self::MAPS_NUMBERS_PER_PAGE)
139 139
                 break;
140 140
         }
141 141
 
@@ -206,23 +206,23 @@  discard block
 block discarded – undo
206 206
 
207 207
         $endpoint = "/search/text/page?sortOrder=" . $sort[$sortOrder];
208 208
 
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;
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;
226 226
 
227 227
         return $this->getMaps($endpoint, $limit);
228 228
     }
Please login to merge, or discard this 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.