file = fopen($filename, 'r'); if (! $this->file) { throw new \RuntimeException('Failed to open file: '.$filename); } // $this->headers = $this->readNextLine(); } public function readNextLine(): ?array { if (($data = fgetcsv($this->file, 1000, ',')) !== false) { return $data; } return null; // End of file or error } }