analyticsModel = model('Analytics' . $params[1] . 'Model'); $this->methodName = 'getData' . (count($params) >= 3 ? $params[2] : ''); return $this->{$method}( (int) $params[0], count($params) >= 4 ? (int) $params[3] : null, ); } public function getData(int $podcastId, ?int $episodeId = null): ResponseInterface { $methodName = $this->methodName; if ($episodeId === null) { return $this->response->setJSON($this->analyticsModel->{$methodName}($podcastId)); } return $this->response->setJSON($this->analyticsModel->{$methodName}($podcastId, $episodeId)); } }