|
@@ -30,15 +30,15 @@ discard block |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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
|
} |
|
@@ -143,25 +143,25 @@ discard block |
|
|
block discarded – undo |
|
143
|
143
|
$maps = []; |
|
144
|
144
|
|
|
145
|
145
|
// Latest |
|
146
|
|
- if($numberOfPage === 0 && $startPage === 0){ |
|
|
146
|
+ if ($numberOfPage === 0 && $startPage === 0) { |
|
147
|
147
|
$apiResult = json_decode($this->callAPI($endpoint)); |
|
148
|
148
|
|
|
149
|
|
- if($apiResult === false || $apiResult == "Not Found") { |
|
|
149
|
+ if ($apiResult === false || $apiResult == "Not Found") { |
|
150
|
150
|
$response->setErrorStatus(true)->setErrorMessage("[getMaps] Something went wrong with the API call while calling the first page."); |
|
151
|
151
|
return $response; |
|
152
|
|
- } else{ |
|
|
152
|
+ } else { |
|
153
|
153
|
foreach ($apiResult->docs as $beatmap) { |
|
154
|
154
|
$maps[] = new BeatMap($beatmap); |
|
155
|
155
|
} |
|
156
|
156
|
} |
|
157
|
157
|
} else { |
|
158
|
|
- for($i = $startPage; $i < ($i + $numberOfPage); $i++){ |
|
|
158
|
+ for ($i = $startPage; $i < ($i + $numberOfPage); $i++) { |
|
159
|
159
|
$apiResult = json_decode($this->callAPI(str_ireplace("page", $i, $endpoint))); |
|
160
|
160
|
|
|
161
|
|
- if($apiResult === false || $apiResult == "Not Found") { |
|
|
161
|
+ if ($apiResult === false || $apiResult == "Not Found") { |
|
162
|
162
|
$response->setErrorStatus(true)->setErrorMessage("[getMaps] Something went wrong with the API call while calling page number " . $i . "."); |
|
163
|
163
|
|
|
164
|
|
- if($apiResult == "Not Found") |
|
|
164
|
+ if ($apiResult == "Not Found") |
|
165
|
165
|
return $response; |
|
166
|
166
|
} |
|
167
|
167
|
|
|
@@ -243,23 +243,23 @@ discard block |
|
|
block discarded – undo |
|
243
|
243
|
|
|
244
|
244
|
$endpoint = "/search/text/page?sortOrder=" . $sort[$sortOrder]; |
|
245
|
245
|
|
|
246
|
|
- if($mapName) $endpoint .= "&q=" . urlencode($mapName); |
|
247
|
|
- if($startDate) $endpoint .= "&from=" . $startDate->format("Y-m-d"); |
|
248
|
|
- if($endDate) $endpoint .= "&to=" . $endDate->format("Y-m-d"); |
|
249
|
|
- if($ranked) $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true); |
|
250
|
|
- if($automapper) $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true); |
|
251
|
|
- if($chroma) $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true); |
|
252
|
|
- if($noodle) $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true); |
|
253
|
|
- if($cinema) $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true); |
|
254
|
|
- if($fullSpread) $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true); |
|
255
|
|
- if($minBpm) $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm; |
|
256
|
|
- if($maxBpm) $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm; |
|
257
|
|
- if($minNps) $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps; |
|
258
|
|
- if($maxNps) $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps; |
|
259
|
|
- if($minRating) $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating; |
|
260
|
|
- if($maxRating) $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating; |
|
261
|
|
- if($minDuration !== null) $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration; |
|
262
|
|
- if($maxDuration !== null) $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration; |
|
|
246
|
+ if ($mapName) $endpoint .= "&q=" . urlencode($mapName); |
|
|
247
|
+ if ($startDate) $endpoint .= "&from=" . $startDate->format("Y-m-d"); |
|
|
248
|
+ if ($endDate) $endpoint .= "&to=" . $endDate->format("Y-m-d"); |
|
|
249
|
+ if ($ranked) $endpoint .= "&ranked=" . /** @scrutinizer ignore-type */ var_export($ranked, true); |
|
|
250
|
+ if ($automapper) $endpoint .= "&automapper=" . /** @scrutinizer ignore-type */ var_export($automapper, true); |
|
|
251
|
+ if ($chroma) $endpoint .= "&chroma=" . /** @scrutinizer ignore-type */ var_export($chroma, true); |
|
|
252
|
+ if ($noodle) $endpoint .= "&noodle=" . /** @scrutinizer ignore-type */ var_export($noodle, true); |
|
|
253
|
+ if ($cinema) $endpoint .= "&cinema=" . /** @scrutinizer ignore-type */ var_export($cinema, true); |
|
|
254
|
+ if ($fullSpread) $endpoint .= "&fullSpread=" . /** @scrutinizer ignore-type */ var_export($fullSpread, true); |
|
|
255
|
+ if ($minBpm) $endpoint .= "&minBpm=" . /** @scrutinizer ignore-type */ $minBpm; |
|
|
256
|
+ if ($maxBpm) $endpoint .= "&maxBpm=" . /** @scrutinizer ignore-type */ $maxBpm; |
|
|
257
|
+ if ($minNps) $endpoint .= "&minNps=" . /** @scrutinizer ignore-type */ $minNps; |
|
|
258
|
+ if ($maxNps) $endpoint .= "&maxNps=" . /** @scrutinizer ignore-type */ $maxNps; |
|
|
259
|
+ if ($minRating) $endpoint .= "&minRating=" . /** @scrutinizer ignore-type */ $minRating; |
|
|
260
|
+ if ($maxRating) $endpoint .= "&maxRating=" . /** @scrutinizer ignore-type */ $maxRating; |
|
|
261
|
+ if ($minDuration !== null) $endpoint .= "&minDuration=" . /** @scrutinizer ignore-type */ $minDuration; |
|
|
262
|
+ if ($maxDuration !== null) $endpoint .= "&maxDuration=" . /** @scrutinizer ignore-type */ $maxDuration; |
|
263
|
263
|
|
|
264
|
264
|
return $this->getMaps($endpoint, $numberOfPage, $startPage); |
|
265
|
265
|
} |
|
@@ -279,7 +279,7 @@ discard block |
|
|
block discarded – undo |
|
279
|
279
|
|
|
280
|
280
|
$apiResult = $this->callAPI($endpoint); |
|
281
|
281
|
|
|
282
|
|
- if($apiResult === false || $apiResult == "Not Found") { |
|
|
282
|
+ if ($apiResult === false || $apiResult == "Not Found") { |
|
283
|
283
|
$response->setErrorStatus(true)->setErrorMessage("[getMap] Something went wrong with the API call."); |
|
284
|
284
|
return $response; |
|
285
|
285
|
} |