示例#1
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));
 }