@@ -110,32 +110,32 @@ discard block |
||
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 |
||
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=" . /** @scrutinizer ignore-type */ $ranked; |
|
213 | - if($automapper) $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ $automapper; |
|
214 | - if($chroma) $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ $chroma; |
|
215 | - if($noodle) $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ $noodle; |
|
216 | - if($cinema) $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ $cinema; |
|
217 | - if($fullSpread) $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ $fullSpread; |
|
218 | - if($minBpm) $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm; |
|
219 | - if($maxBpm) $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm; |
|
220 | - if($minNps) $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps; |
|
221 | - if($maxNps) $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps; |
|
222 | - if($minRating) $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating; |
|
223 | - if($maxRating) $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating; |
|
224 | - if($minDuration) $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration; |
|
225 | - if($maxDuration) $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $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=" . /** @scrutinizer ignore-type */ $ranked; |
|
213 | + if ($automapper) $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ $automapper; |
|
214 | + if ($chroma) $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ $chroma; |
|
215 | + if ($noodle) $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ $noodle; |
|
216 | + if ($cinema) $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ $cinema; |
|
217 | + if ($fullSpread) $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ $fullSpread; |
|
218 | + if ($minBpm) $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm; |
|
219 | + if ($maxBpm) $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm; |
|
220 | + if ($minNps) $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps; |
|
221 | + if ($maxNps) $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps; |
|
222 | + if ($minRating) $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating; |
|
223 | + if ($maxRating) $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating; |
|
224 | + if ($minDuration) $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration; |
|
225 | + if ($maxDuration) $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration; |
|
226 | 226 | |
227 | 227 | return $this->getMaps($endpoint, $limit); |
228 | 228 | } |
@@ -116,13 +116,15 @@ discard block |
||
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 |
||
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 |
||
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=" . /** @scrutinizer ignore-type */ $ranked; |
|
213 | - if($automapper) $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ $automapper; |
|
214 | - if($chroma) $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ $chroma; |
|
215 | - if($noodle) $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ $noodle; |
|
216 | - if($cinema) $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ $cinema; |
|
217 | - if($fullSpread) $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ $fullSpread; |
|
218 | - if($minBpm) $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm; |
|
219 | - if($maxBpm) $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm; |
|
220 | - if($minNps) $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps; |
|
221 | - if($maxNps) $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps; |
|
222 | - if($minRating) $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating; |
|
223 | - if($maxRating) $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating; |
|
224 | - if($minDuration) $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration; |
|
225 | - if($maxDuration) $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $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=" . /** @scrutinizer ignore-type */ $ranked; |
|
223 | + } |
|
224 | + if($automapper) { |
|
225 | + $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ $automapper; |
|
226 | + } |
|
227 | + if($chroma) { |
|
228 | + $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ $chroma; |
|
229 | + } |
|
230 | + if($noodle) { |
|
231 | + $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ $noodle; |
|
232 | + } |
|
233 | + if($cinema) { |
|
234 | + $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ $cinema; |
|
235 | + } |
|
236 | + if($fullSpread) { |
|
237 | + $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ $fullSpread; |
|
238 | + } |
|
239 | + if($minBpm) { |
|
240 | + $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm; |
|
241 | + } |
|
242 | + if($maxBpm) { |
|
243 | + $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm; |
|
244 | + } |
|
245 | + if($minNps) { |
|
246 | + $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps; |
|
247 | + } |
|
248 | + if($maxNps) { |
|
249 | + $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps; |
|
250 | + } |
|
251 | + if($minRating) { |
|
252 | + $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating; |
|
253 | + } |
|
254 | + if($maxRating) { |
|
255 | + $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating; |
|
256 | + } |
|
257 | + if($minDuration) { |
|
258 | + $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration; |
|
259 | + } |
|
260 | + if($maxDuration) { |
|
261 | + $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration; |
|
262 | + } |
|
226 | 263 | |
227 | 264 | return $this->getMaps($endpoint, $limit); |
228 | 265 | } |