public function toJson() { $this->openFile(); $output = array(); foreach ($this->fileContent as $line) { $buff = new CSVRecord(explode($this->separator, $line), $this->columns); $output[] = $buff->toArray(); } return json_encode($output); }
public function parseLines(string $lines) : \Iterator { $schema = $this->getSchema(); $lines = $this->getLines($lines); $indices = array_keys($lines); return new \ArrayIterator(array_map(function ($values, $index) use($schema) { return CSVRecord::create($schema, $index, $values); }, $lines, $indices)); }