*/ class GetMediaInfoHandler implements HandlerInterface { public function __construct( private readonly TmdbClient $tmdb, ) {} public function handle(CommandInterface $command): ResultInterface { $handlers = [ MediaType::Movie->value => 'getMovieDetails', MediaType::TvShow->value => 'getTvshowDetails', ]; $handler = $handlers[$command->mediaType]; $media = $this->$handler($command); $relatedMedia = $this->tmdb->relatedMedia($media->tmdbId, $command->mediaType); return new GetMediaInfoResult($media, $relatedMedia, $command->season, $command->episode); } private function getMovieDetails(CommandInterface $command): TmdbResult { return $this->tmdb->movieDetails($command->imdbId); } private function getTvshowDetails(CommandInterface $command): TmdbResult { $media = $this->tmdb->tvshowDetails($command->imdbId); return $media; } }