Fix psalm
All checks were successful
repod / nextcloud-25 (push) Successful in 36s
repod / nextcloud-27 (push) Successful in 36s
repod / nodejs (push) Successful in 1m34s

This commit is contained in:
Michel Roux 2023-07-03 00:20:18 +02:00
parent 559c6f9881
commit a3ac95f948

View File

@ -28,16 +28,17 @@ class TopController extends Controller
*/ */
public function index(int $limit = 10): JSONResponse { public function index(int $limit = 10): JSONResponse {
if (!in_array($limit, [10, 25, 50])) { if (!in_array($limit, [10, 25, 50])) {
return new JSONResponse('Invalid limit, can be 10, 25 or 50.', Http::STATUS_BAD_REQUEST); return new JSONResponse(['Invalid limit, can be 10, 25 or 50.'], Http::STATUS_BAD_REQUEST);
} }
try { try {
$client = $this->clientService->newClient(); $client = $this->clientService->newClient();
$response = $client->get("https://rss.applemarketingtools.com/api/v2/fr/podcasts/top/{$limit}/podcasts.json"); $response = $client->get("https://rss.applemarketingtools.com/api/v2/fr/podcasts/top/{$limit}/podcasts.json");
$json = json_decode($response->getBody(), flags: JSON_THROW_ON_ERROR); /** @var array $json */
$json = json_decode((string) $response->getBody(), flags: JSON_THROW_ON_ERROR);
return new JSONResponse($json, $response->getStatusCode()); return new JSONResponse($json, $response->getStatusCode());
} catch (Exception $e) { } catch (Exception $e) {
return new JSONResponse($e->getMessage(), Http::STATUS_INTERNAL_SERVER_ERROR); return new JSONResponse([$e->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR);
} }
} }
} }