diff --git a/src/Mooc/Videos/Application/Find/VideoFinder.php b/src/Mooc/Videos/Application/Find/VideoFinder.php index f74f297e8..27121a6dd 100644 --- a/src/Mooc/Videos/Application/Find/VideoFinder.php +++ b/src/Mooc/Videos/Application/Find/VideoFinder.php @@ -4,21 +4,26 @@ namespace CodelyTv\Mooc\Videos\Application\Find; -use CodelyTv\Mooc\Videos\Domain\VideoFinder as DomainVideoFinder; use CodelyTv\Mooc\Videos\Domain\VideoId; use CodelyTv\Mooc\Videos\Domain\VideoRepository; +use CodelyTv\Mooc\Videos\Domain\Video; +use CodelyTv\Mooc\Videos\Domain\VideoNotFound; final class VideoFinder { - private DomainVideoFinder $finder; - public function __construct(VideoRepository $repository) + public function __construct(private VideoRepository $repository) { - $this->finder = new DomainVideoFinder($repository); } - public function __invoke(VideoId $id) + public function __invoke(VideoId $id): Video { - return $this->finder->__invoke($id); + $video = $this->repository->search($id); + + if (null === $video) { + throw new VideoNotFound($id); + } + + return $video; } } diff --git a/src/Mooc/Videos/Application/Update/VideoTitleUpdater.php b/src/Mooc/Videos/Application/Update/VideoTitleUpdater.php index 4f473cdab..a48ccbc86 100644 --- a/src/Mooc/Videos/Application/Update/VideoTitleUpdater.php +++ b/src/Mooc/Videos/Application/Update/VideoTitleUpdater.php @@ -4,7 +4,7 @@ namespace CodelyTv\Mooc\Videos\Application\Update; -use CodelyTv\Mooc\Videos\Domain\VideoFinder; +use CodelyTv\Mooc\Videos\Application\Find\VideoFinder; use CodelyTv\Mooc\Videos\Domain\VideoId; use CodelyTv\Mooc\Videos\Domain\VideoRepository; use CodelyTv\Mooc\Videos\Domain\VideoTitle; diff --git a/src/Mooc/Videos/Domain/VideoFinder.php b/src/Mooc/Videos/Domain/VideoFinder.php deleted file mode 100644 index 1a07f8403..000000000 --- a/src/Mooc/Videos/Domain/VideoFinder.php +++ /dev/null @@ -1,23 +0,0 @@ -repository->search($id); - - if (null === $video) { - throw new VideoNotFound($id); - } - - return $video; - } -}