text = $text; } /** * Checking an item that already is done keeps who did it and when. */ public function check(int $userId, DateTimeImmutable $at): void { if ($this->doneAt !== null) { return; } $this->doneAt = $at; $this->doneBy = $userId; } public function uncheck(): void { $this->doneAt = null; $this->doneBy = null; } public function swapOrderWith(self $other): void { [$this->sortOrder, $other->sortOrder] = [$other->sortOrder, $this->sortOrder]; } public function id(): ?int { return $this->id; } public function taskId(): int { return $this->taskId; } public function text(): ChecklistItemText { return $this->text; } public function sortOrder(): int { return $this->sortOrder; } public function isDone(): bool { return $this->doneAt !== null; } public function doneAt(): ?DateTimeImmutable { return $this->doneAt; } public function doneBy(): ?int { return $this->doneBy; } }