Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/Readers/SplCsvReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,21 @@ public function getRecord(): array|false
$reader->seek($this->getCurrentPosition());
$record = $reader->current();

if ($record !== false && $record !== []) {
$this->position++;
if ($record === false) {
return false;
}

if (is_string($record)) {
return false;
}

if ($this->isInvalidRecord($record)) {
return false;
}

return is_array($record) ? $record !== [] ? $record : false : false;
$this->position++;

return $record;
}

/**
Expand Down Expand Up @@ -225,4 +235,12 @@ public function getSource(): string
{
return $this->config->getPath();
}

/**
* Check if the record is considered invalid
*/
private function isInvalidRecord(array $record): bool
{
return count($record) === 1 && $record[0] === null;
}
}