/** * @param UuidInterface $reservationId * @param \DateTime $givenAwayAt * * @throws BookInReservationAlreadyGivenAway */ public function giveAway(UuidInterface $reservationId, \DateTime $givenAwayAt) { $reservation = $this->reservations->get($reservationId); if ($this->reservations->existsAlreadyGivenOfBook($reservation->bookId())) { throw new BookInReservationAlreadyGivenAway(sprintf('Book with id %s in reservation with id %s was already given away.', $reservation->bookId(), $reservation->id())); } $reservation->giveAway($givenAwayAt); $this->reservations->save($reservation); }
/** * @param UuidInterface $reservationId * @param UuidInterface $bookId * @param string $email */ public function create(UuidInterface $reservationId, UuidInterface $bookId, $email) { $this->reservations->save(new Reservation($reservationId, $bookId, $email)); }