Skip to content

Commit

Permalink
Improve Docblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Dec 10, 2015
1 parent 8558a84 commit 66d71d9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 43 deletions.
4 changes: 2 additions & 2 deletions src/Config/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ trait Output
* The Input file BOM character
* @var string
*/
protected $input_bom = '';
protected $input_bom;

/**
* The Output file BOM character
Expand Down Expand Up @@ -113,7 +113,7 @@ public function getOutputBOM()
*/
public function getInputBOM()
{
if (!$this->input_bom) {
if (null === $this->input_bom) {
$bom = [
AbstractCsv::BOM_UTF32_BE, AbstractCsv::BOM_UTF32_LE,
AbstractCsv::BOM_UTF16_BE, AbstractCsv::BOM_UTF16_LE, AbstractCsv::BOM_UTF8,
Expand Down
83 changes: 42 additions & 41 deletions src/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,21 @@ class Reader extends AbstractCsv
protected $stream_filter_mode = STREAM_FILTER_READ;

/**
* Return a Filtered Iterator
* Returns a sequential array of all CSV lines
*
* The callable function will be applied to each Iterator item
*
* @param callable|null $callable a callable function
*
* @return array
*/
public function fetchAll(callable $callable = null)
{
return iterator_to_array($this->fetch($callable), false);
}

/**
* Fetch the next row from a result set
*
* @param callable|null $callable a callable function to be applied to each Iterator item
*
Expand Down Expand Up @@ -62,20 +76,6 @@ protected function applyCallable(Iterator $iterator, callable $callable = null)
return $iterator;
}

/**
* Returns a sequential array of all CSV lines
*
* The callable function will be applied to each Iterator item
*
* @param callable|null $callable a callable function
*
* @return array
*/
public function fetchAll(callable $callable = null)
{
return iterator_to_array($this->fetch($callable), false);
}

/**
* Applies a callback function on the CSV
*
Expand Down Expand Up @@ -124,7 +124,7 @@ public function fetchOne($offset = 0)
}

/**
* Returns a single column from the CSV data
* Returns the next value from a single CSV column
*
* The callable function will be applied to each value to be return
*
Expand Down Expand Up @@ -155,7 +155,7 @@ public function fetchColumn($columnIndex = 0, callable $callable = null)
}

/**
* Retrive CSV data as pairs
* Retrieve CSV data as pairs
*
* Fetches an associative array of all rows as key-value pairs (first
* column is the key, second column is the value).
Expand All @@ -164,6 +164,28 @@ public function fetchColumn($columnIndex = 0, callable $callable = null)
* - the first CSV column is used to provide the keys
* - the second CSV column is used to provide the value
*
* If the value from the column key index is duplicated its corresponding value will
* be overwritten
*
* @param int $offsetIndex The column index to serve as offset
* @param int $valueIndex The column index to serve as value
* @param callable|null $callable A callable to be applied to each of the rows to be returned.
*
* @return array
*/
public function fetchPairsWithoutDuplicates($offsetIndex = 0, $valueIndex = 1, callable $callable = null)
{
return iterator_to_array($this->fetchPairs($offsetIndex, $valueIndex, $callable), true);
}

/**
* Fetches the next key-value pairs from a result set (first
* column is the key, second column is the value).
*
* By default if no column index is provided:
* - the first CSV column is used to provide the keys
* - the second CSV column is used to provide the value
*
* @param int $offsetIndex The column index to serve as offset
* @param int $valueIndex The column index to serve as value
* @param callable|null $callable A callable to be applied to each of the rows to be returned.
Expand Down Expand Up @@ -206,31 +228,10 @@ protected function generatePairs(Iterator $iterator)
}

/**
* Retrive CSV data as pairs
*
* Fetches an associative array of all rows as key-value pairs (first
* column is the key, second column is the value).
*
* By default if no column index is provided:
* - the first CSV column is used to provide the keys
* - the second CSV column is used to provide the value
*
* @param int $offsetIndex The column index to serve as offset
* @param int $valueIndex The column index to serve as value
* @param callable|null $callable A callable to be applied to each of the rows to be returned.
*
* @return array
*/
public function fetchPairsWithoutDuplicates($offsetIndex = 0, $valueIndex = 1, callable $callable = null)
{
return iterator_to_array($this->fetchPairs($offsetIndex, $valueIndex, $callable), true);
}

/**
* Returns a sequential array of all CSV lines;
* Fetch the next row from a result set
*
* The rows are presented as associated arrays
* The callable function will be applied to each Iterator item
* The callable function will be applied to each row
*
* @param int|array $offset_or_keys the name for each key member OR the row Index to be
* used as the associated named keys
Expand All @@ -239,7 +240,7 @@ public function fetchPairsWithoutDuplicates($offsetIndex = 0, $valueIndex = 1, c
*
* @throws InvalidArgumentException If the submitted keys are invalid
*
* @return Iterator|array
* @return Iterator
*/
public function fetchAssoc($offset_or_keys = 0, callable $callable = null)
{
Expand Down

0 comments on commit 66d71d9

Please sign in to comment.