details->status->locksTime()) { $this->completedAt = null; return; } $this->completedAt ??= $now; } public function completedAt(): ?DateTimeImmutable { return $this->completedAt; } /** * Replaces the details and returns what changed, for the history. * * @return list */ public function changeDetails(JobDetails $details): array { $before = $this->details->comparable(); $after = $details->comparable(); $this->details = $details; $changes = []; foreach ($after as $field => $value) { if (($before[$field] ?? null) !== $value) { $changes[] = new FieldChange($field, $before[$field] ?? null, $value); } } return $changes; } /** * @return list */ public function changeStatus(JobStatus $status): array { return $this->changeDetails($this->details->withStatus($status)); } /** * @return list */ public function changePriority(Priority $priority): array { return $this->changeDetails($this->details->withPriority($priority)); } public function id(): ?int { return $this->id; } public function number(): JobNumber { return $this->number; } public function details(): JobDetails { return $this->details; } public function createdBy(): int { return $this->createdBy; } }