summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorignace nyamagana butera <nyamsprod@gmail.com>2015-12-10 14:18:05 +0100
committerignace nyamagana butera <nyamsprod@gmail.com>2015-12-10 14:18:05 +0100
commit66d71d97c642710d7019afb514b56ec60d5dc038 (patch)
tree81ed8e1ddc3bdeaf8eebf6f421d1dd4cc49f6c1f /src
parent8558a84f1ef29ff9b1a585c8fa768132d9164405 (diff)
downloadcsv-66d71d97c642710d7019afb514b56ec60d5dc038.zip
csv-66d71d97c642710d7019afb514b56ec60d5dc038.tar.gz
csv-66d71d97c642710d7019afb514b56ec60d5dc038.tar.bz2
Improve Docblocks
Diffstat (limited to 'src')
-rw-r--r--src/Config/Output.php4
-rw-r--r--src/Reader.php83
2 files changed, 44 insertions, 43 deletions
diff --git a/src/Config/Output.php b/src/Config/Output.php
index baf5aa2..2e1faf3 100644
--- a/src/Config/Output.php
+++ b/src/Config/Output.php
@@ -39,7 +39,7 @@ trait Output
* The Input file BOM character
* @var string
*/
- protected $input_bom = '';
+ protected $input_bom;
/**
* The Output file BOM character
@@ -113,7 +113,7 @@ trait Output
*/
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,
diff --git a/src/Reader.php b/src/Reader.php
index c50b449..6aee834 100644
--- a/src/Reader.php
+++ b/src/Reader.php
@@ -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
*
@@ -63,20 +77,6 @@ class Reader extends AbstractCsv
}
/**
- * 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
*
* The callback function must return TRUE in order to continue
@@ -124,7 +124,7 @@ class Reader extends AbstractCsv
}
/**
- * 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
*
@@ -155,7 +155,7 @@ class Reader extends AbstractCsv
}
/**
- * 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).
@@ -164,6 +164,28 @@ class Reader extends AbstractCsv
* - 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.
@@ -206,31 +228,10 @@ class Reader extends AbstractCsv
}
/**
- * 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
@@ -239,7 +240,7 @@ class Reader extends AbstractCsv
*
* @throws InvalidArgumentException If the submitted keys are invalid
*
- * @return Iterator|array
+ * @return Iterator
*/
public function fetchAssoc($offset_or_keys = 0, callable $callable = null)
{