Files
torsearch/src/Search/Action/Handler/SearchHandler.php

26 lines
655 B
PHP

<?php
namespace App\Search\Action\Handler;
use App\Search\Action\Result\SearchResult;
use App\Tmdb\Tmdb;
use OneToMany\RichBundle\Contract\CommandInterface;
use OneToMany\RichBundle\Contract\HandlerInterface;
use OneToMany\RichBundle\Contract\ResultInterface;
/*** @implements HandlerInterface<SearchResult> */
class SearchHandler implements HandlerInterface
{
public function __construct(
private Tmdb $tmdb,
) {}
public function handle(CommandInterface $command): ResultInterface
{
return new SearchResult(
term: $command->term,
results: $this->tmdb->search($command->term)
);
}
}