userId = $UserId ?? ''; $this->metricsReader = $metricsReader; } /** * * @NoAdminRequired * @NoCSRFRequired * * @return JSONResponse */ public function metrics(): JSONResponse { $metrics = $this->metricsReader->metrics($this->userId); $metricsArrays = array_map(function (PodcastMetrics $metric) { return $metric->toArray(); }, $metrics); return new JSONResponse([ 'subscriptions' => $metricsArrays, ]); } }