@@ -180,7 +180,7 @@ |
||
| 180 | 180 | { |
| 181 | 181 | $response = []; |
| 182 | 182 | |
| 183 | - foreach($this->bm->versions as $version) { |
|
| 183 | + foreach ($this->bm->versions as $version) { |
|
| 184 | 184 | $response[] = new BeatMapVersion($version); |
| 185 | 185 | } |
| 186 | 186 | |
@@ -30,15 +30,15 @@ discard block |
||
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | private function autoload($directory) { |
| 33 | - if(is_dir($directory)) { |
|
| 33 | + if (is_dir($directory)) { |
|
| 34 | 34 | $scan = scandir($directory); |
| 35 | 35 | unset($scan[0], $scan[1]); //unset . and .. |
| 36 | - foreach($scan as $file) { |
|
| 37 | - if(is_dir($directory."/".$file)) { |
|
| 38 | - $this->autoload($directory."/".$file); |
|
| 36 | + foreach ($scan as $file) { |
|
| 37 | + if (is_dir($directory . "/" . $file)) { |
|
| 38 | + $this->autoload($directory . "/" . $file); |
|
| 39 | 39 | } else { |
| 40 | - if(strpos($file, '.php') !== false) { |
|
| 41 | - include_once($directory."/".$file); |
|
| 40 | + if (strpos($file, '.php') !== false) { |
|
| 41 | + include_once($directory . "/" . $file); |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | $apiResult = $this->callAPI($endpoint); |
| 84 | 84 | |
| 85 | - if($apiResult === false || $apiResult == "Not Found") { |
|
| 85 | + if ($apiResult === false || $apiResult == "Not Found") { |
|
| 86 | 86 | $response->setErrorStatus(true)->setErrorMessage("[getMap] Something went wrong with the API call."); |
| 87 | 87 | return $response; |
| 88 | 88 | } |
@@ -173,25 +173,25 @@ discard block |
||
| 173 | 173 | $maps = []; |
| 174 | 174 | |
| 175 | 175 | // Latest |
| 176 | - if($numberOfPage === 0 && $startPage === 0){ |
|
| 176 | + if ($numberOfPage === 0 && $startPage === 0) { |
|
| 177 | 177 | $apiResult = json_decode($this->callAPI($endpoint)); |
| 178 | 178 | |
| 179 | - if($apiResult === false || $apiResult == "Not Found") { |
|
| 179 | + if ($apiResult === false || $apiResult == "Not Found") { |
|
| 180 | 180 | $response->setErrorStatus(true)->setErrorMessage("[getMaps] Something went wrong with the API call while calling the first page."); |
| 181 | 181 | return $response; |
| 182 | - } else{ |
|
| 182 | + } else { |
|
| 183 | 183 | foreach ($apiResult->docs as $beatmap) { |
| 184 | 184 | $maps[] = new BeatMap($beatmap); |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | } else { |
| 188 | - for($i = $startPage; $i < ($i + $numberOfPage); $i++){ |
|
| 188 | + for ($i = $startPage; $i < ($i + $numberOfPage); $i++) { |
|
| 189 | 189 | $apiResult = json_decode($this->callAPI(str_ireplace("page", $i, $endpoint))); |
| 190 | 190 | |
| 191 | - if($apiResult === false || $apiResult == "Not Found") { |
|
| 191 | + if ($apiResult === false || $apiResult == "Not Found") { |
|
| 192 | 192 | $response->setErrorStatus(true)->setErrorMessage("[getMaps] Something went wrong with the API call while calling page number " . $i . "."); |
| 193 | 193 | |
| 194 | - if($apiResult == "Not Found") |
|
| 194 | + if ($apiResult == "Not Found") |
|
| 195 | 195 | return $response; |
| 196 | 196 | } |
| 197 | 197 | |
@@ -273,23 +273,23 @@ discard block |
||
| 273 | 273 | |
| 274 | 274 | $endpoint = "/search/text/page?sortOrder=" . $sort[$sortOrder]; |
| 275 | 275 | |
| 276 | - if($mapName) $endpoint .= "&q=" . urlencode($mapName); |
|
| 277 | - if($startDate) $endpoint .= "&from=" . $startDate->format("Y-m-d"); |
|
| 278 | - if($endDate) $endpoint .= "&to=" . $endDate->format("Y-m-d"); |
|
| 279 | - if($ranked) $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true); |
|
| 280 | - if($automapper) $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true); |
|
| 281 | - if($chroma) $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true); |
|
| 282 | - if($noodle) $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true); |
|
| 283 | - if($cinema) $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true); |
|
| 284 | - if($fullSpread) $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true); |
|
| 285 | - if($minBpm) $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm; |
|
| 286 | - if($maxBpm) $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm; |
|
| 287 | - if($minNps) $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps; |
|
| 288 | - if($maxNps) $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps; |
|
| 289 | - if($minRating) $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating; |
|
| 290 | - if($maxRating) $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating; |
|
| 291 | - if($minDuration !== null) $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration; |
|
| 292 | - if($maxDuration !== null) $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration; |
|
| 276 | + if ($mapName) $endpoint .= "&q=" . urlencode($mapName); |
|
| 277 | + if ($startDate) $endpoint .= "&from=" . $startDate->format("Y-m-d"); |
|
| 278 | + if ($endDate) $endpoint .= "&to=" . $endDate->format("Y-m-d"); |
|
| 279 | + if ($ranked) $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true); |
|
| 280 | + if ($automapper) $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true); |
|
| 281 | + if ($chroma) $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true); |
|
| 282 | + if ($noodle) $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true); |
|
| 283 | + if ($cinema) $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true); |
|
| 284 | + if ($fullSpread) $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true); |
|
| 285 | + if ($minBpm) $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm; |
|
| 286 | + if ($maxBpm) $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm; |
|
| 287 | + if ($minNps) $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps; |
|
| 288 | + if ($maxNps) $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps; |
|
| 289 | + if ($minRating) $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating; |
|
| 290 | + if ($maxRating) $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating; |
|
| 291 | + if ($minDuration !== null) $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration; |
|
| 292 | + if ($maxDuration !== null) $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration; |
|
| 293 | 293 | |
| 294 | 294 | return $this->getMapsByEndpoint($endpoint, $numberOfPage, $startPage); |
| 295 | 295 | } |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | $apiResult = $this->callAPI($endpoint); |
| 311 | 311 | |
| 312 | - if($apiResult === false || $apiResult == "Not Found") { |
|
| 312 | + if ($apiResult === false || $apiResult == "Not Found") { |
|
| 313 | 313 | $response->setErrorStatus(true)->setErrorMessage("[getMap] Something went wrong with the API call."); |
| 314 | 314 | return $response; |
| 315 | 315 | } |
@@ -191,8 +191,9 @@ discard block |
||
| 191 | 191 | if($apiResult === false || $apiResult == "Not Found") { |
| 192 | 192 | $response->setErrorStatus(true)->setErrorMessage("[getMaps] Something went wrong with the API call while calling page number " . $i . "."); |
| 193 | 193 | |
| 194 | - if($apiResult == "Not Found") |
|
| 195 | - return $response; |
|
| 194 | + if($apiResult == "Not Found") { |
|
| 195 | + return $response; |
|
| 196 | + } |
|
| 196 | 197 | } |
| 197 | 198 | |
| 198 | 199 | foreach ($apiResult->docs as $beatmap) { |
@@ -273,23 +274,57 @@ discard block |
||
| 273 | 274 | |
| 274 | 275 | $endpoint = "/search/text/page?sortOrder=" . $sort[$sortOrder]; |
| 275 | 276 | |
| 276 | - if($mapName) $endpoint .= "&q=" . urlencode($mapName); |
|
| 277 | - if($startDate) $endpoint .= "&from=" . $startDate->format("Y-m-d"); |
|
| 278 | - if($endDate) $endpoint .= "&to=" . $endDate->format("Y-m-d"); |
|
| 279 | - if($ranked) $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true); |
|
| 280 | - if($automapper) $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true); |
|
| 281 | - if($chroma) $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true); |
|
| 282 | - if($noodle) $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true); |
|
| 283 | - if($cinema) $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true); |
|
| 284 | - if($fullSpread) $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true); |
|
| 285 | - if($minBpm) $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm; |
|
| 286 | - if($maxBpm) $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm; |
|
| 287 | - if($minNps) $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps; |
|
| 288 | - if($maxNps) $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps; |
|
| 289 | - if($minRating) $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating; |
|
| 290 | - if($maxRating) $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating; |
|
| 291 | - if($minDuration !== null) $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration; |
|
| 292 | - if($maxDuration !== null) $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration; |
|
| 277 | + if($mapName) { |
|
| 278 | + $endpoint .= "&q=" . urlencode($mapName); |
|
| 279 | + } |
|
| 280 | + if($startDate) { |
|
| 281 | + $endpoint .= "&from=" . $startDate->format("Y-m-d"); |
|
| 282 | + } |
|
| 283 | + if($endDate) { |
|
| 284 | + $endpoint .= "&to=" . $endDate->format("Y-m-d"); |
|
| 285 | + } |
|
| 286 | + if($ranked) { |
|
| 287 | + $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true); |
|
| 288 | + } |
|
| 289 | + if($automapper) { |
|
| 290 | + $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true); |
|
| 291 | + } |
|
| 292 | + if($chroma) { |
|
| 293 | + $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true); |
|
| 294 | + } |
|
| 295 | + if($noodle) { |
|
| 296 | + $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true); |
|
| 297 | + } |
|
| 298 | + if($cinema) { |
|
| 299 | + $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true); |
|
| 300 | + } |
|
| 301 | + if($fullSpread) { |
|
| 302 | + $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true); |
|
| 303 | + } |
|
| 304 | + if($minBpm) { |
|
| 305 | + $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm; |
|
| 306 | + } |
|
| 307 | + if($maxBpm) { |
|
| 308 | + $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm; |
|
| 309 | + } |
|
| 310 | + if($minNps) { |
|
| 311 | + $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps; |
|
| 312 | + } |
|
| 313 | + if($maxNps) { |
|
| 314 | + $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps; |
|
| 315 | + } |
|
| 316 | + if($minRating) { |
|
| 317 | + $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating; |
|
| 318 | + } |
|
| 319 | + if($maxRating) { |
|
| 320 | + $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating; |
|
| 321 | + } |
|
| 322 | + if($minDuration !== null) { |
|
| 323 | + $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration; |
|
| 324 | + } |
|
| 325 | + if($maxDuration !== null) { |
|
| 326 | + $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration; |
|
| 327 | + } |
|
| 293 | 328 | |
| 294 | 329 | return $this->getMapsByEndpoint($endpoint, $numberOfPage, $startPage); |
| 295 | 330 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $l_Handles = []; |
| 35 | 35 | foreach ($p_URLs as $l_URL) |
| 36 | 36 | { |
| 37 | - $l_CURL = curl_init($this->apiUrl.$apiUrlExt.$l_URL); |
|
| 37 | + $l_CURL = curl_init($this->apiUrl . $apiUrlExt . $l_URL); |
|
| 38 | 38 | curl_setopt($l_CURL, CURLOPT_USERAGENT, $this->userAgent); |
| 39 | 39 | curl_setopt($l_CURL, CURLOPT_RETURNTRANSFER, true); |
| 40 | 40 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | mkdir($targetDir, 0777, true); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if(substr($targetDir, -1) !== "/") |
|
| 90 | + if (substr($targetDir, -1) !== "/") |
|
| 91 | 91 | $targetDir .= "/"; |
| 92 | 92 | |
| 93 | 93 | //The path & filename to save to. |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | $result = curl_exec($ch); |
| 103 | 103 | |
| 104 | - if(curl_errno($ch) === 0) { |
|
| 104 | + if (curl_errno($ch) === 0) { |
|
| 105 | 105 | $response->pushDownloadMapHash($hash); |
| 106 | 106 | echo "Ok "; |
| 107 | 107 | } else { |
@@ -41,8 +41,9 @@ discard block |
||
| 41 | 41 | $l_Handles[] = $l_CURL; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - foreach ($l_Handles as $l_Current) |
|
| 45 | - curl_multi_add_handle($l_Multi, $l_Current); |
|
| 44 | + foreach ($l_Handles as $l_Current) { |
|
| 45 | + curl_multi_add_handle($l_Multi, $l_Current); |
|
| 46 | + } |
|
| 46 | 47 | |
| 47 | 48 | $l_RunningHandles = null; |
| 48 | 49 | |
@@ -57,10 +58,11 @@ discard block |
||
| 57 | 58 | { |
| 58 | 59 | $l_Error = curl_error($l_Current); |
| 59 | 60 | |
| 60 | - if (!empty($l_Error) || curl_getinfo($l_Current, CURLINFO_HTTP_CODE) !== 200) |
|
| 61 | - $l_Result[] = false; |
|
| 62 | - else |
|
| 63 | - $l_Result[] = new BeatMap(json_decode(curl_multi_getcontent($l_Current))); |
|
| 61 | + if (!empty($l_Error) || curl_getinfo($l_Current, CURLINFO_HTTP_CODE) !== 200) { |
|
| 62 | + $l_Result[] = false; |
|
| 63 | + } else { |
|
| 64 | + $l_Result[] = new BeatMap(json_decode(curl_multi_getcontent($l_Current))); |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | curl_multi_remove_handle($l_Multi, $l_Current); |
| 66 | 68 | } |
@@ -87,8 +89,9 @@ discard block |
||
| 87 | 89 | mkdir($targetDir, 0777, true); |
| 88 | 90 | } |
| 89 | 91 | |
| 90 | - if(substr($targetDir, -1) !== "/") |
|
| 91 | - $targetDir .= "/"; |
|
| 92 | + if(substr($targetDir, -1) !== "/") { |
|
| 93 | + $targetDir .= "/"; |
|
| 94 | + } |
|
| 92 | 95 | |
| 93 | 96 | //The path & filename to save to. |
| 94 | 97 | $saveTo = $targetDir . $hash . $extension; |