Skip to content

Commit c3063d5

Browse files
authored
Prevent fatal error on wrong delimiter
1 parent 2a1ee5a commit c3063d5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Model/Import/FromCsv.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use function array_combine;
1717
use function array_map;
1818
use function array_shift;
19+
use function count;
1920

2021
class FromCsv
2122
{
@@ -43,6 +44,11 @@ public function execute(string $filePath, Options $options): void
4344

4445
$data = [];
4546
foreach ($rows as $row) {
47+
if ($keysCount !== count($row)) {
48+
throw new InputException(
49+
new Phrase('The number of column does not match the keys. Please verify the field separator.')
50+
);
51+
}
4652
$data[] = array_combine($keys, $row);
4753
}
4854

0 commit comments

Comments
 (0)