PHP Class Box\Spout\Reader\CSV\RowIterator

Inheritance: implements Box\Spout\Reader\IteratorInterface
Datei anzeigen Open project: box/spout

Protected Properties

Property Type Description
$encodedEOLDelimiter End of line delimiter, encoded using the same encoding as the CSV
$encoding Encoding of the CSV file to be read
$encodingHelper Helper to work with different encodings
$fieldDelimiter Defines the character used to delimit fields (one character only)
$fieldEnclosure Defines the character used to enclose fields (one character only)
$filePointer Pointer to the CSV file to read
$globalFunctionsHelper Helper to work with global functions
$hasReachedEndOfFile Indicates whether all rows have been read
$inputEOLDelimiter End of line delimiter, given by the user as input.
$numReadRows Number of read rows
$rowDataBuffer Buffer used to store the row data, while checking if there are more rows to read
$shouldPreserveEmptyRows Whether empty rows should be returned or skipped

Public Methods

Method Description
__construct ( resource $filePointer, ReaderOptions $options, Box\Spout\Common\Helper\GlobalFunctionsHelper $globalFunctionsHelper )
current ( ) : array | null Return the current element from the buffer
end ( ) : void Cleans up what was created to iterate over the object.
key ( ) : integer Return the key of the current element
next ( ) : void Move forward to next element. Reads data for the next unprocessed row.
rewind ( ) : void Rewind the Iterator to the first element
valid ( ) : boolean Checks if current position is valid

Protected Methods

Method Description
getEncodedEOLDelimiter ( ) : string Returns the end of line delimiter, encoded using the same encoding as the CSV.
getNextUTF8EncodedRow ( ) : array | false Returns the next row, converted if necessary to UTF-8.
isEmptyLine ( array | boolean $lineData ) : boolean
readDataForNextRow ( ) : void
rewindAndSkipBom ( ) : void This rewinds and skips the BOM if inserted at the beginning of the file by moving the file pointer after it, so that it is not read.
shouldReadNextRow ( array | boolean $currentRowData ) : boolean

Method Details

__construct() public method

public __construct ( resource $filePointer, ReaderOptions $options, Box\Spout\Common\Helper\GlobalFunctionsHelper $globalFunctionsHelper )
$filePointer resource Pointer to the CSV file to read
$options ReaderOptions
$globalFunctionsHelper Box\Spout\Common\Helper\GlobalFunctionsHelper

current() public method

Return the current element from the buffer
public current ( ) : array | null
return array | null

end() public method

Cleans up what was created to iterate over the object.
public end ( ) : void
return void

getEncodedEOLDelimiter() protected method

The return value is cached.
protected getEncodedEOLDelimiter ( ) : string
return string

getNextUTF8EncodedRow() protected method

As fgetcsv() does not manage correctly encoding for non UTF-8 data, we remove manually whitespace with ltrim or rtrim (depending on the order of the bytes)
protected getNextUTF8EncodedRow ( ) : array | false
return array | false The row for the current file pointer, encoded in UTF-8 or FALSE if nothing to read

isEmptyLine() protected method

protected isEmptyLine ( array | boolean $lineData ) : boolean
$lineData array | boolean Array containing the cells value for the line
return boolean Whether the given line is empty

key() public method

Return the key of the current element
public key ( ) : integer
return integer

next() public method

Move forward to next element. Reads data for the next unprocessed row.
public next ( ) : void
return void

readDataForNextRow() protected method

protected readDataForNextRow ( ) : void
return void

rewind() public method

Rewind the Iterator to the first element
public rewind ( ) : void
return void

rewindAndSkipBom() protected method

This rewinds and skips the BOM if inserted at the beginning of the file by moving the file pointer after it, so that it is not read.
protected rewindAndSkipBom ( ) : void
return void

shouldReadNextRow() protected method

protected shouldReadNextRow ( array | boolean $currentRowData ) : boolean
$currentRowData array | boolean
return boolean Whether the data for the current row can be returned or if we need to keep reading

valid() public method

Checks if current position is valid
public valid ( ) : boolean
return boolean

Property Details

$encodedEOLDelimiter protected_oe property

End of line delimiter, encoded using the same encoding as the CSV
protected $encodedEOLDelimiter

$encoding protected_oe property

Encoding of the CSV file to be read
protected $encoding

$encodingHelper protected_oe property

Helper to work with different encodings
protected $encodingHelper

$fieldDelimiter protected_oe property

Defines the character used to delimit fields (one character only)
protected $fieldDelimiter

$fieldEnclosure protected_oe property

Defines the character used to enclose fields (one character only)
protected $fieldEnclosure

$filePointer protected_oe property

Pointer to the CSV file to read
protected $filePointer

$globalFunctionsHelper protected_oe property

Helper to work with global functions
protected $globalFunctionsHelper

$hasReachedEndOfFile protected_oe property

Indicates whether all rows have been read
protected $hasReachedEndOfFile

$inputEOLDelimiter protected_oe property

End of line delimiter, given by the user as input.
protected $inputEOLDelimiter

$numReadRows protected_oe property

Number of read rows
protected $numReadRows

$rowDataBuffer protected_oe property

Buffer used to store the row data, while checking if there are more rows to read
protected $rowDataBuffer

$shouldPreserveEmptyRows protected_oe property

Whether empty rows should be returned or skipped
protected $shouldPreserveEmptyRows