Example #1
0
 public function reopenTodo()
 {
     if (!$this->status->isDone()) {
         throw Exception\CannotReopenTodo::notMarkedDone($this);
     }
     $this->recordThat(TodoWasReopened::withStatus($this->todoId, TodoStatus::fromString(TodoStatus::OPEN)));
 }
Example #2
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));
 }