transactions->run(function () use ($jobId, $data, $actorUserId): void { $job = $this->jobs->findById($jobId) ?? throw new CustomerJobNotFound($jobId); $changes = $job->changeDetails($this->detailsFactory->build($data, $job->details())); $job->recordCompletion($this->clock->now()); if ($changes === []) { return; } $this->jobs->save($job); $this->jobs->recordChanges($jobId, $actorUserId, $changes); }); } }