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