hours = $hours; $this->note = self::text($note); } /** * Adds more hours to the day's entry; a new note continues the old one. */ public function addHours(WorkedHours $hours, ?string $note): void { $this->hours = $this->hours->plus($hours); $note = self::text($note); if ($note !== null) { $this->note = $this->note === null ? $note : $this->note."\n".$note; } } public function id(): ?int { return $this->id; } public function userId(): int { return $this->userId; } public function taskId(): int { return $this->taskId; } public function jobId(): int { return $this->jobId; } public function workTypeId(): int { return $this->workTypeId; } public function workedOn(): DateTimeImmutable { return $this->workedOn; } public function hours(): WorkedHours { return $this->hours; } public function note(): ?string { return $this->note; } private static function text(?string $value): ?string { $value = $value === null ? '' : trim($value); return $value === '' ? null : $value; } }