@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function __construct(string $userAgent, bool $needAutoloader = false) |
28 | 28 | { |
29 | - if($needAutoloader) |
|
29 | + if ($needAutoloader) |
|
30 | 30 | $this->autoload("./"); |
31 | 31 | |
32 | 32 | $this->userAgent = $userAgent; |
@@ -34,15 +34,15 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | private function autoload($directory) { |
37 | - if(is_dir($directory)) { |
|
37 | + if (is_dir($directory)) { |
|
38 | 38 | $scan = scandir($directory); |
39 | 39 | unset($scan[0], $scan[1]); //unset . and .. |
40 | - foreach($scan as $file) { |
|
41 | - if(is_dir($directory."/".$file)) { |
|
42 | - $this->autoload($directory."/".$file); |
|
40 | + foreach ($scan as $file) { |
|
41 | + if (is_dir($directory . "/" . $file)) { |
|
42 | + $this->autoload($directory . "/" . $file); |
|
43 | 43 | } else { |
44 | - if(strpos($file, '.php') !== false) { |
|
45 | - include_once($directory."/".$file); |
|
44 | + if (strpos($file, '.php') !== false) { |
|
45 | + include_once($directory . "/" . $file); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | $apiResult = $this->callAPI($endpoint); |
88 | 88 | |
89 | - if($apiResult === false || $apiResult == "Not Found") { |
|
89 | + if ($apiResult === false || $apiResult == "Not Found") { |
|
90 | 90 | $response->setErrorStatus(true)->setErrorMessage("[getMap] Something went wrong with the API call."); |
91 | 91 | return $response; |
92 | 92 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | $apiResult = $this->callAPI($endpoint); |
147 | 147 | |
148 | - if($apiResult === false || $apiResult == "Not Found") { |
|
148 | + if ($apiResult === false || $apiResult == "Not Found") { |
|
149 | 149 | $response->setErrorStatus(true)->setErrorMessage("[getMap] Something went wrong with the API call."); |
150 | 150 | return $response; |
151 | 151 | } |
@@ -191,15 +191,15 @@ discard block |
||
191 | 191 | $callNumber = 0; |
192 | 192 | $result = new ResponseMaps(); |
193 | 193 | |
194 | - if(count($hashes) < 2) { |
|
194 | + if (count($hashes) < 2) { |
|
195 | 195 | return $result->setErrorStatus(true)->setErrorMessage("This functions require a minimum of 2 hashes in the array"); |
196 | 196 | } |
197 | 197 | |
198 | - foreach($hashes as $hash) { |
|
198 | + foreach ($hashes as $hash) { |
|
199 | 199 | $hashesString .= $hash; |
200 | 200 | |
201 | - if($i !== 0 && $i % self::MAX_HASHES_NUMBER === 0) { |
|
202 | - if($callNumber === self::MAX_CALL_PER_SECS) { |
|
201 | + if ($i !== 0 && $i % self::MAX_HASHES_NUMBER === 0) { |
|
202 | + if ($callNumber === self::MAX_CALL_PER_SECS) { |
|
203 | 203 | sleep(1); |
204 | 204 | $callNumber = 0; |
205 | 205 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | $mapsArray = array_merge($mapsArray, $maps->getBeatMaps()); |
211 | 211 | |
212 | - if(!isset($mapsArray["errorStatus"]) || !$mapsArray["errorStatus"]) { |
|
212 | + if (!isset($mapsArray["errorStatus"]) || !$mapsArray["errorStatus"]) { |
|
213 | 213 | $mapsArray["errorStatus"] = $maps->getErrorStatus(); |
214 | 214 | $mapsArray["errorMessage"] = $maps->getErrorMessage(); |
215 | 215 | } |
@@ -223,18 +223,18 @@ discard block |
||
223 | 223 | } |
224 | 224 | |
225 | 225 | |
226 | - if($i !== 0) { |
|
226 | + if ($i !== 0) { |
|
227 | 227 | $maps = $this->getMaps($hashesString); |
228 | 228 | $mapsArray = array_merge($mapsArray, $maps->getBeatMaps()); |
229 | 229 | |
230 | - if(!isset($mapsArray["errorStatus"]) || !$mapsArray["errorStatus"]) { |
|
230 | + if (!isset($mapsArray["errorStatus"]) || !$mapsArray["errorStatus"]) { |
|
231 | 231 | $mapsArray["errorStatus"] = $maps->getErrorStatus(); |
232 | 232 | $mapsArray["errorMessage"] = $maps->getErrorMessage(); |
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
236 | - if(isset($mapsArray["errorStatus"]) && $mapsArray["errorStatus"]) |
|
237 | - $result->setErrorStatus( $mapsArray["errorStatus"])->setErrorMessage( $mapsArray["errorMessage"]); |
|
236 | + if (isset($mapsArray["errorStatus"]) && $mapsArray["errorStatus"]) |
|
237 | + $result->setErrorStatus($mapsArray["errorStatus"])->setErrorMessage($mapsArray["errorMessage"]); |
|
238 | 238 | |
239 | 239 | unset($mapsArray["errorStatus"]); |
240 | 240 | unset($mapsArray["errorMessage"]); |
@@ -256,20 +256,20 @@ discard block |
||
256 | 256 | $callNumber = 0; |
257 | 257 | |
258 | 258 | // Latest |
259 | - if($numberOfPage === 0 && $startPage === 0){ |
|
259 | + if ($numberOfPage === 0 && $startPage === 0) { |
|
260 | 260 | $apiResult = json_decode($this->callAPI(str_ireplace("page", 0, $endpoint))); |
261 | 261 | |
262 | - if($apiResult === false || $apiResult == "Not Found") { |
|
262 | + if ($apiResult === false || $apiResult == "Not Found") { |
|
263 | 263 | $response->setErrorStatus(true)->setErrorMessage("[getMaps] Something went wrong with the API call while calling the first page."); |
264 | 264 | return $response; |
265 | - } else{ |
|
265 | + } else { |
|
266 | 266 | foreach ($apiResult->docs as $beatmap) { |
267 | 267 | $maps[] = new BeatMap($beatmap); |
268 | 268 | } |
269 | 269 | } |
270 | 270 | } else { |
271 | - for($i = $startPage; $i < ($i + $numberOfPage); $i++){ |
|
272 | - if($callNumber === self::MAX_CALL_PER_SECS) { |
|
271 | + for ($i = $startPage; $i < ($i + $numberOfPage); $i++) { |
|
272 | + if ($callNumber === self::MAX_CALL_PER_SECS) { |
|
273 | 273 | sleep(1); |
274 | 274 | $callNumber = 0; |
275 | 275 | } |
@@ -277,10 +277,10 @@ discard block |
||
277 | 277 | $apiResult = json_decode($this->callAPI(str_ireplace("page", $i, $endpoint))); |
278 | 278 | $callNumber++; |
279 | 279 | |
280 | - if($apiResult === false || $apiResult == "Not Found") { |
|
280 | + if ($apiResult === false || $apiResult == "Not Found") { |
|
281 | 281 | $response->setErrorStatus(true)->setErrorMessage("[getMaps] Something went wrong with the API call while calling page number " . $i . "."); |
282 | 282 | |
283 | - if($apiResult == "Not Found") |
|
283 | + if ($apiResult == "Not Found") |
|
284 | 284 | return $response; |
285 | 285 | } |
286 | 286 | |
@@ -362,23 +362,23 @@ discard block |
||
362 | 362 | |
363 | 363 | $endpoint = "/search/text/page?sortOrder=" . $sort[$sortOrder]; |
364 | 364 | |
365 | - if($mapName) $endpoint .= "&q=" . urlencode($mapName); |
|
366 | - if($startDate) $endpoint .= "&from=" . $startDate->format("Y-m-d"); |
|
367 | - if($endDate) $endpoint .= "&to=" . $endDate->format("Y-m-d"); |
|
368 | - if($ranked) $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true); |
|
369 | - if($automapper) $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true); |
|
370 | - if($chroma) $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true); |
|
371 | - if($noodle) $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true); |
|
372 | - if($cinema) $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true); |
|
373 | - if($fullSpread) $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true); |
|
374 | - if($minBpm) $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm; |
|
375 | - if($maxBpm) $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm; |
|
376 | - if($minNps) $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps; |
|
377 | - if($maxNps) $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps; |
|
378 | - if($minRating) $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating; |
|
379 | - if($maxRating) $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating; |
|
380 | - if($minDuration !== null) $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration; |
|
381 | - if($maxDuration !== null) $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration; |
|
365 | + if ($mapName) $endpoint .= "&q=" . urlencode($mapName); |
|
366 | + if ($startDate) $endpoint .= "&from=" . $startDate->format("Y-m-d"); |
|
367 | + if ($endDate) $endpoint .= "&to=" . $endDate->format("Y-m-d"); |
|
368 | + if ($ranked) $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true); |
|
369 | + if ($automapper) $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true); |
|
370 | + if ($chroma) $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true); |
|
371 | + if ($noodle) $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true); |
|
372 | + if ($cinema) $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true); |
|
373 | + if ($fullSpread) $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true); |
|
374 | + if ($minBpm) $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm; |
|
375 | + if ($maxBpm) $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm; |
|
376 | + if ($minNps) $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps; |
|
377 | + if ($maxNps) $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps; |
|
378 | + if ($minRating) $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating; |
|
379 | + if ($maxRating) $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating; |
|
380 | + if ($minDuration !== null) $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration; |
|
381 | + if ($maxDuration !== null) $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration; |
|
382 | 382 | |
383 | 383 | return $this->getMapsByEndpoint($endpoint, $numberOfPage, $startPage); |
384 | 384 | } |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | |
399 | 399 | $apiResult = $this->callAPI($endpoint); |
400 | 400 | |
401 | - if($apiResult === false || $apiResult == "Not Found") { |
|
401 | + if ($apiResult === false || $apiResult == "Not Found") { |
|
402 | 402 | $response->setErrorStatus(true)->setErrorMessage("[getMap] Something went wrong with the API call."); |
403 | 403 | return $response; |
404 | 404 | } |