. */ namespace SP\Infrastructure\File; /** * Class CsvFileHandler */ final class CsvFileHandler implements \SP\Domain\File\Ports\CsvFileHandler { public function __construct(private readonly FileHandlerInterface $fileHandler) { } /** * Read a CSV file * * @throws FileException */ public function readCsv(string $delimiter): iterable { $handler = $this->fileHandler->open(); while (($fields = fgetcsv($handler, 0, $delimiter)) !== false) { yield $fields; } $this->fileHandler->close(); } }