コード例 #1
0
ファイル: FileOfNameHandlerSpec.php プロジェクト: bengor/file
 function it_does_not_get_the_file_because_the_name_does_not_exist(FileRepository $repository, FileOfNameQuery $query)
 {
     $query->name()->shouldBeCalled()->willReturn('file.pdf');
     $name = new FileName('file.pdf');
     $repository->fileOfName($name)->shouldBeCalled()->willReturn(null);
     $this->shouldThrow(FileDoesNotExistException::class)->during__invoke($query);
 }
コード例 #2
0
ファイル: FileOfNameHandler.php プロジェクト: bengor/file
 /**
  * Handles the given query.
  *
  * @param FileOfNameQuery $aQuery The query
  *
  * @throws FileDoesNotExistException when the file name does not exist
  *
  * @return mixed
  */
 public function __invoke(FileOfNameQuery $aQuery)
 {
     $fileName = new FileName($aQuery->name());
     $file = $this->repository->fileOfName($fileName);
     if (null === $file) {
         throw new FileDoesNotExistException();
     }
     $this->dataTransformer->write($file);
     return $this->dataTransformer->read();
 }