diff --git a/src/Writer.php b/src/Writer.php index 3632ea54..3f2836ba 100644 --- a/src/Writer.php +++ b/src/Writer.php @@ -119,7 +119,9 @@ private function formatRow(array $row) { if (self::NULL_AS_EXCEPTION == $this->null_handling_mode) { return $row; - } elseif (self::NULL_AS_EMPTY == $this->null_handling_mode) { + } + + if (self::NULL_AS_EMPTY == $this->null_handling_mode) { foreach ($row as &$value) { if (is_null($value)) { $value = ''; diff --git a/test/WriterTest.php b/test/WriterTest.php index ecfcb907..75ff3ee2 100644 --- a/test/WriterTest.php +++ b/test/WriterTest.php @@ -57,6 +57,7 @@ public function testInsertNullToSkipCell() 'john,doe,john.doe@example.com', ['john', null, 'john.doe@example.com'], ]; + $this->csv->setNullHandlingMode(Writer::NULL_AS_SKIP_CELL); foreach ($expected as $row) { $this->csv->insertOne($row);