Minor Tweak

This commit is contained in:
oleibman
2024-10-11 14:06:10 -07:00
parent 545b098acd
commit f981ef95c9
2 changed files with 12 additions and 2 deletions
+4 -2
View File
@@ -562,10 +562,12 @@ class Csv extends BaseReader
*/
public function setEscapeCharacter(string $escapeCharacter): self
{
if (PHP_VERSION_ID < 90000) {
$this->escapeCharacter = $escapeCharacter;
if (PHP_VERSION_ID >= 90000 && $escapeCharacter !== '') {
throw new ReaderException('Escape character must be null string for Php9+');
}
$this->escapeCharacter = $escapeCharacter;
return $this;
}
@@ -114,6 +114,10 @@ class CsvTest extends TestCase
public function testEscapeCharacters(): void
{
if (PHP_VERSION_ID >= 90000) {
$this->expectException(ReaderException::class);
$this->expectExceptionMessage('Escape character must be null string');
}
$reader = (new Csv())->setEscapeCharacter('"');
$worksheet = $reader->load('tests/data/Reader/CSV/backslash.csv')
->getActiveSheet();
@@ -230,6 +234,10 @@ class CsvTest extends TestCase
*/
public function testInferSeparator(string $escape, string $delimiter): void
{
if (PHP_VERSION_ID >= 90000 && $escape !== '') {
$this->expectException(ReaderException::class);
$this->expectExceptionMessage('Escape character must be null string');
}
$reader = new Csv();
$reader->setEscapeCharacter($escape);
$filename = 'tests/data/Reader/CSV/escape.csv';