Skip to content

Commit

Permalink
Allow for import to not be stored in memory (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
pushchris authored and rap2hpoutre committed Jan 9, 2019
1 parent 51f33ec commit 10d37b6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Importable.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,13 @@ private function importSheet(SheetInterface $sheet, callable $callback = null)
} elseif ($count_header < $count_row = count($row)) {
$row = array_slice($row, 0, $count_header);
}
$collection[] = $callback ? $callback(array_combine($headers, $row)) : array_combine($headers, $row);
if ($callback) {
if ($result = $callback(array_combine($headers, $row))) {
$collection[] = $result;
}
} else {
$collection[] = array_combine($headers, $row);
}
}
} else {
foreach ($sheet->getRowIterator() as $row) {
Expand Down

0 comments on commit 10d37b6

Please sign in to comment.