From a3ac95f948c0922d25b5d95c56be2e2256eb1245 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Mon, 3 Jul 2023 00:20:18 +0200 Subject: [PATCH] Fix psalm --- lib/Controller/TopController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Controller/TopController.php b/lib/Controller/TopController.php index bfcb143..c0e681f 100644 --- a/lib/Controller/TopController.php +++ b/lib/Controller/TopController.php @@ -28,16 +28,17 @@ class TopController extends Controller */ public function index(int $limit = 10): JSONResponse { 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 { $client = $this->clientService->newClient(); $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()); } catch (Exception $e) { - return new JSONResponse($e->getMessage(), Http::STATUS_INTERNAL_SERVER_ERROR); + return new JSONResponse([$e->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR); } } }