transactions->run(function () use ($jobId, $taskId): array { $task = $this->tasks->findForJob($jobId, $taskId) ?? throw new TaskNotFound($jobId, $taskId); if ($this->usage->hasTimeEntries($taskId)) { throw new TaskHasTimeEntries; } $imagePaths = $this->images->filePathsOfTask($taskId); $this->tasks->delete($task); return $imagePaths; }); $this->imageFiles->delete($imagePaths); } }