We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example of implementation (does not require doc update):
/** * Extract data from the input. */ public function extract(): \Generator { $handle = fopen($this->input, 'r'); $columns = $this->makeColumns($handle); $rowIndex = 1; while ($row = fgets($handle)) { $rowIndex++; yield new Row($this->makeRow($row, $columns, $rowIndex)); } fclose($handle); } /** * Converts the row string to array. */ protected function makeRow(string $row, array $columns, int $rowIndex): array { $row = str_getcsv($row, $this->delimiter, $this->enclosure); $data = []; $rowCount = count($row); $columnsCount = count($columns); if ($rowCount !== $columnsCount) { throw new \LogicException("Row with index #{$rowIndex} only contains $rowCount elements while $columnsCount were expected."); } foreach ($columns as $column => $index) { $data[$column] = $row[$index - 1]; } return $data; }
The text was updated successfully, but these errors were encountered:
Done
Sorry, something went wrong.
ecourtial
No branches or pull requests
Example of implementation (does not require doc update):
The text was updated successfully, but these errors were encountered: