Skip to content

Commit

Permalink
Fix exception
Browse files Browse the repository at this point in the history
  • Loading branch information
mantas-done committed Apr 10, 2024
1 parent 87ae0a9 commit 9ec77fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/Code/Converters/CsvConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,7 @@ private static function csvToArray($content)

$csv2 = [];
foreach ($csv as $row) {
if ($row[0] == '' && !isset($row[1])) { // empty line
continue;
}
if (trim($row[0]) === '' && trim($row[1]) === '') {
if ($row[0] == '' && (!isset($row[1]) || trim($row[1]) === '')) { // empty line
continue;
}
$csv2[] = $row;
Expand Down
8 changes: 8 additions & 0 deletions tests/formats/CsvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,12 @@ public function testDifferentElementCountShouldntBeInterpretedAsCsv()
$converter = Helpers::getConverterByFileContent($csv);
$this->assertTrue(get_class($converter) !== CsvConverter::class, get_class($converter));
}
public function testShouldntThrowException()
{
$csv = '1,a
' . ' ' . '
2,b';
$converter = Helpers::getConverterByFileContent($csv);
$this->assertTrue(get_class($converter) !== CsvConverter::class, get_class($converter));
}
}

0 comments on commit 9ec77fc

Please sign in to comment.