Exemplo n.º 1
0
 /**
  * @param TodoReminder $reminder
  * @throws Exception\InvalidReminder
  */
 public function remindAssignee(TodoReminder $reminder)
 {
     if ($this->status->isDone()) {
         throw Exception\TodoNotOpen::triedToAddReminder($reminder, $this->status);
     }
     if (!$this->reminder->equals($reminder)) {
         throw Exception\InvalidReminder::reminderNotCurrent($this->reminder, $reminder);
     }
     if (!$this->reminder->isOpen()) {
         throw Exception\InvalidReminder::alreadyReminded();
     }
     if ($reminder->isInTheFuture()) {
         throw Exception\InvalidReminder::reminderInTheFuture($reminder);
     }
     $this->recordThat(TodoAssigneeWasReminded::forAssignee($this->todoId, $this->assigneeId, $reminder->close()));
 }
Exemplo n.º 2
0
 /**
  * @param UserId $userId
  * @param TodoReminder $reminder
  * @return void
  * @throws Exception\InvalidReminder
  */
 public function addReminder(UserId $userId, TodoReminder $reminder)
 {
     if (!$this->assigneeId()->sameValueAs($userId)) {
         throw Exception\InvalidReminder::userIsNotAssignee($userId, $this->assigneeId());
     }
     if ($reminder->isInThePast()) {
         throw Exception\InvalidReminder::reminderInThePast($reminder);
     }
     if ($this->status->isDone()) {
         throw Exception\TodoNotOpen::triedToAddReminder($reminder, $this->status);
     }
     $this->recordThat(ReminderWasAddedToTodo::byUserToDate($this->todoId, $this->assigneeId, $reminder));
 }
Exemplo n.º 3
0
 /**
  * @param UserId $userId
  * @param TodoDeadline $deadline
  * @return void
  * @throws Exception\InvalidDeadline
  * @throws Exception\TodoNotOpen
  */
 public function addDeadline(UserId $userId, TodoDeadline $deadline)
 {
     if (!$this->assigneeId()->sameValueAs($userId)) {
         throw Exception\InvalidDeadline::userIsNotAssignee($userId, $this->assigneeId());
     }
     if ($deadline->isInThePast()) {
         throw Exception\InvalidDeadline::deadlineInThePast($deadline);
     }
     if ($this->status->isDone()) {
         throw Exception\TodoNotOpen::triedToAddDeadline($deadline, $this->status);
     }
     $this->recordThat(DeadlineWasAddedToTodo::byUserToDate($this->todoId, $this->assigneeId, $deadline));
 }