*/ class SearchHandler implements HandlerInterface { public function __construct( private TmdbClient $tmdb, ) {} public function handle(CommandInterface $command): ResultInterface { $result = $this->tmdb->search($command->term); if ($result instanceof TmdbResult) { return new RedirectToMediaResult( imdbId: $result->imdbId, mediaType: $result->mediaType, ); } return new SearchResult( term: $command->term, results: $this->tmdb->search($command->term) ); } }