Are we forgetting something? the author should be notified by email, yeah! That's true. Let's see in Listing 16 how we have updated the UseCase for doing the job:
class RateIdeaUseCase
{
private $ideaRepository;
private $authorNotifier;
public function __construct(
IdeaRepository $ideaRepository,
AuthorNotifier $authorNotifier
) {
$this->ideaRepository = $ideaRepository;
$this->authorNotifier = $authorNotifier;
}
public function execute(RateIdeaRequest $request)
{
$ideaId = $request->ideaId;
$rating = $request->rating;
try {
$idea = $this->ideaRepository->find($ideaId);
} catch(Exception $e) {
throw new RepositoryNotAvailableException();
}
if (!$idea) {
throw new IdeaDoesNotExistException();
}
try {
...