public function current()
{
// If the CSV has no column headers just return the line
if (empty($this->columnHeaders)) {
return $this->file->current();
}
// Since the CSV has column headers use them to construct an associative array for the columns in this line
if ($this->valid()) {
$current = $this->file->current();
$current = $this->convertEncodingRows($current);
$line = $current;
// See if values for duplicate headers should be merged
if (self::DUPLICATE_HEADERS_MERGE === $this->duplicateHeadersFlag) {
$line = $this->mergeDuplicates($line);
}
// Count the number of elements in both: they must be equal.
if (count($this->columnHeaders) === count($line)) {
return array_combine(array_keys($this->columnHeaders), $line);
} else {
return $line;
}
}
return null;
}