/** * @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)); }
/** * @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())); }