shouldThrowException) { throw $this->shouldThrowException; } $this->downloadedFiles[$url] = $destination; } public function downloadBatch(array $urls, TempDirectory $tempDir, string $jobId): array { if ($this->shouldThrowException) { throw $this->shouldThrowException; } $results = []; foreach ($urls as $index => $url) { $destination = sprintf('%s/%03d.jpg', $tempDir->getPath(), $index + 1); $this->download($url, $destination); $results[] = new DownloadResult($destination, $url); } return $results; } public function simulateError(\Exception $exception): void { $this->shouldThrowException = $exception; } public function getDownloadedFiles(): array { return $this->downloadedFiles; } }