protected function combineHeader(Iterator $iterator, array $header): Iterator
    {
        if ([] === $header) {
            return $iterator;
        }

        $field_count = count($header);
        $mapper = static function (array $record) use ($header, $field_count): array {
            if (count($record) != $field_count) {
                $record = array_slice(array_pad($record, $field_count, null), 0, $field_count);
            }

            return array_combine($header, $record);
        };

        return new MapIterator($iterator, $mapper);
    }
protected function combineHeader(Iterator $iterator, array $header): Iterator
    {
        if ([] === $header) {
            return $iterator;
        }

        $field_count = count($header);
        $mapper = static function (array $record) use ($header, $field_count): array {
            if (count($record) != $field_count) {
                $record = array_slice(array_pad($record, $field_count, null), 0, $field_count);
            }

            return array_combine($header, $record);
        };

        return new MapIterator($iterator, $mapper);
    }
protected function combineHeader ( Iterator $ iterator , array $ header ) : Iterator { if ( [ ] === $ header ) { return $ iterator ; } $ field_count = count ( $ header ) ; $ mapper = static function ( array $ record ) use ( $ header , $ field_count ) : array { if ( count ( $ record ) != $ field_count ) { $ record = array_slice ( array_pad ( $ record , $ field_count , null ) , 0 , $ field_count ) ; } return array_combine ( $ header , $ record ) ; } ; return new MapIterator ( $ iterator , $ mapper ) ; }
Combine the CSV header to each record if present.

@param string[] $header
Combine the CSV header to each record if present .