diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/AbstractCsv.php | 70 | ||||
-rw-r--r-- | src/Config/Controls.php | 26 | ||||
-rw-r--r-- | src/Config/Output.php | 20 | ||||
-rw-r--r-- | src/Reader.php | 21 | ||||
-rw-r--r-- | src/Writer.php | 12 |
5 files changed, 75 insertions, 74 deletions
diff --git a/src/AbstractCsv.php b/src/AbstractCsv.php index 902efc2..7dc905a 100644 --- a/src/AbstractCsv.php +++ b/src/AbstractCsv.php @@ -87,7 +87,7 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate use Modifier\StreamFilter; /** - * Create a new instance + * Creates a new instance * * The path must be an SplFileInfo object * an object that implements the `__toString` method @@ -105,7 +105,7 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate } /** - * Return a normalize path which could be a SplFileObject + * Returns a normalize path which could be a SplFileObject * or a string path * * @param object|string $path the filepath @@ -130,7 +130,34 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate } /** - * Create a {@link AbstractCsv} from a string + * Returns the CSV Iterator + * + * @return \Iterator + */ + public function getIterator() + { + $iterator = $this->path; + if (! $iterator instanceof SplFileObject) { + $iterator = new SplFileObject($this->getStreamFilterPath(), $this->open_mode); + } + $iterator->setCsvControl($this->delimiter, $this->enclosure, $this->escape); + $iterator->setFlags($this->flags); + + return $iterator; + } + + /** + * Returns the CSV Iterator for conversion + * + * @return \Iterator + */ + protected function getConvertionIterator() + { + return $this->getIterator(); + } + + /** + * Creates a {@link AbstractCsv} from a string * * The path can be: * - an SplFileInfo, @@ -168,7 +195,7 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate } /** - * Create a {@link AbstractCsv} from a SplFileObject + * Creates a {@link AbstractCsv} from a SplFileObject * * The path can be: * - a SplFileObject, @@ -192,7 +219,7 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate } /** - * Create a {@link AbstractCsv} from a string + * Creates a {@link AbstractCsv} from a string * * The string must be an object that implements the `__toString` method, * or a string @@ -214,34 +241,7 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate } /** - * Return the CSV Iterator - * - * @return \Iterator - */ - public function getIterator() - { - $iterator = $this->path; - if (! $iterator instanceof SplFileObject) { - $iterator = new SplFileObject($this->getStreamFilterPath(), $this->open_mode); - } - $iterator->setCsvControl($this->delimiter, $this->enclosure, $this->escape); - $iterator->setFlags($this->flags); - - return $iterator; - } - - /** - * Return the Iterator for conversion - * - * @return \Iterator - */ - protected function getConvertionIterator() - { - return $this->getIterator(); - } - - /** - * Create a {@link AbstractCsv} instance from another {@link AbstractCsv} object + * Creates a {@link AbstractCsv} instance from another {@link AbstractCsv} object * * @param string $class_name the class to be instantiated * @param string $open_mode the file open mode flag @@ -264,7 +264,7 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate } /** - * Create a {@link Writer} instance from a {@link AbstractCsv} object + * Creates a {@link Writer} instance from a {@link AbstractCsv} object * * @param string $open_mode the file open mode flag * @@ -276,7 +276,7 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate } /** - * Create a {@link Reader} instance from a {@link AbstractCsv} object + * Creates a {@link Reader} instance from a {@link AbstractCsv} object * * @param string $open_mode the file open mode flag * diff --git a/src/Config/Controls.php b/src/Config/Controls.php index 952cb32..538e77c 100644 --- a/src/Config/Controls.php +++ b/src/Config/Controls.php @@ -62,14 +62,14 @@ trait Controls protected $newline = "\n"; /** - * return a SplFileOjbect + * Returns the CSV Iterator * - * @return \SplFileOjbect + * @return \Iterator */ abstract public function getIterator(); /** - * set the field delimeter + * Sets the field delimeter * * @param string $delimiter * @@ -88,7 +88,7 @@ trait Controls } /** - * return the current field delimiter + * Returns the current field delimiter * * @return string */ @@ -98,7 +98,7 @@ trait Controls } /** - * detect the actual number of row according to a delimiter + * Detects the actual number of row according to a delimiter * * @param string $delimiter a CSV delimiter * @param int $nb_rows the number of row to consider @@ -118,7 +118,7 @@ trait Controls } /** - * Detect the CSV file delimiter + * Detects the CSV file delimiters * * @param int $nb_rows * @param string[] $delimiters additional delimiters @@ -149,7 +149,7 @@ trait Controls } /** - * set the field enclosure + * Sets the field enclosure * * @param string $enclosure * @@ -168,7 +168,7 @@ trait Controls } /** - * return the current field enclosure + * Returns the current field enclosure * * @return string */ @@ -178,7 +178,7 @@ trait Controls } /** - * set the field escape character + * Sets the field escape character * * @param string $escape * @@ -197,7 +197,7 @@ trait Controls } /** - * return the current field escape character + * Returns the current field escape character * * @return string */ @@ -207,7 +207,7 @@ trait Controls } /** - * Set the Flags associated to the CSV SplFileObject + * Sets the Flags associated to the CSV SplFileObject * * @param int $flags * @@ -238,7 +238,7 @@ trait Controls /** - * set the newline sequence characters + * Sets the newline sequence characters * * @param string $newline * @@ -252,7 +252,7 @@ trait Controls } /** - * return the current newline sequence characters + * Returns the current newline sequence characters * * @return string */ diff --git a/src/Config/Output.php b/src/Config/Output.php index 8b9f178..67c4e3d 100644 --- a/src/Config/Output.php +++ b/src/Config/Output.php @@ -47,21 +47,21 @@ trait Output protected $output_bom; /** - * Return the CSV Iterator + * Returns the CSV Iterator * * @return \Iterator */ abstract protected function getConvertionIterator(); /** - * Return the CSV Iterator + * Returns the CSV Iterator * - * @return \SplFileObject + * @return \Iterator */ abstract public function getIterator(); /** - * Set the CSV encoding charset + * Sets the CSV encoding charset * * @param string $str * @@ -80,7 +80,7 @@ trait Output } /** - * Get the source CSV encoding charset + * Gets the source CSV encoding charset * * @return string */ @@ -90,7 +90,7 @@ trait Output } /** - * Set the BOM sequence to prepend the CSV on output + * Sets the BOM sequence to prepend the CSV on output * * @param string $str The BOM sequence * @@ -150,7 +150,7 @@ trait Output } /** - * Output all data on the CSV file + * Outputs all data on the CSV file * * @param string $filename CSV downloaded name if present adds extra headers * @@ -171,7 +171,7 @@ trait Output } /** - * Output all data from the CSV + * Outputs all data from the CSV * * @return int Returns the number of characters read from the handle * and passed through to the output. @@ -240,7 +240,7 @@ trait Output } /** - * Return a HTML table representation of the CSV Table + * Returns a HTML table representation of the CSV Table * * @param string $class_name optional classname * @@ -255,7 +255,7 @@ trait Output } /** - * transform a CSV into a XML + * Transforms a CSV into a XML * * @param string $root_name XML root node name * @param string $row_name XML row node name diff --git a/src/Reader.php b/src/Reader.php index 7e22347..9f4070a 100644 --- a/src/Reader.php +++ b/src/Reader.php @@ -28,7 +28,7 @@ use LimitIterator; class Reader extends AbstractCsv { /** - * Iterator Query Trait + * Query Filter Trait */ use Modifier\QueryFilter; @@ -38,7 +38,7 @@ class Reader extends AbstractCsv protected $stream_filter_mode = STREAM_FILTER_READ; /** - * Return a Filtered Iterator + * Returns a Filtered Iterator * * @param callable $callable a callable function to be applied to each Iterator item * @@ -74,7 +74,7 @@ class Reader extends AbstractCsv } /** - * Apply a callback function on the CSV + * Applies a callback function on the CSV * * The callback function must return TRUE in order to continue * iterating over the iterator. @@ -97,7 +97,7 @@ class Reader extends AbstractCsv } /** - * Return a single column from the CSV data + * Returns a single column from the CSV data * * The callable function will be applied to each value to be return * @@ -128,7 +128,7 @@ class Reader extends AbstractCsv } /** - * Return a single row from the CSV + * Returns a single row from the CSV * * @param int $offset * @@ -147,7 +147,7 @@ class Reader extends AbstractCsv } /** - * Return a sequential array of all CSV lines + * Returns a sequential array of all CSV lines * * The callable function will be applied to each Iterator item * @@ -161,7 +161,7 @@ class Reader extends AbstractCsv } /** - * Return a sequential array of all CSV lines; + * Returns a sequential array of all CSV lines; * * The rows are presented as associated arrays * The callable function will be applied to each Iterator item @@ -187,7 +187,8 @@ class Reader extends AbstractCsv } /** - * Select the array to be used as key for the fetchAssoc method + * Selects the array to be used as key for the fetchAssoc method + * * @param array|int $offset_or_keys the assoc key OR the row Index to be used * as the key index * @@ -214,7 +215,7 @@ class Reader extends AbstractCsv } /** - * Return a single row from the CSV without filtering + * Returns a single row from the CSV without filtering * * @param int $offset * @@ -239,7 +240,7 @@ class Reader extends AbstractCsv } /** - * Validate the array to be used by the fetchAssoc method + * Validates the array to be used by the fetchAssoc method * * @param array $keys * diff --git a/src/Writer.php b/src/Writer.php index 1145604..f835bd6 100644 --- a/src/Writer.php +++ b/src/Writer.php @@ -43,9 +43,9 @@ class Writer extends AbstractCsv use Modifier\RowFilter; /** - * Add multiple lines to the CSV your are generating + * Adds multiple lines to the CSV document * - * a simple helper/Wrapper method around insertOne + * a simple wrapper method around insertOne * * @param \Traversable|array $rows a multidimentional array or a Traversable object * @@ -69,7 +69,7 @@ class Writer extends AbstractCsv } /** - * Add a new CSV row to the generated CSV + * Adds a single line to a CSV document * * @param string[]|string $row a string, an array or an object implementing to '__toString' method * @@ -93,8 +93,8 @@ class Writer extends AbstractCsv } /** - * set the csv container as a SplFileObject instance - * insure we use the same object for insertion to + * Sets the csv container as a \SplFileObject instance + * and Insures we use the same object for insertion to * avoid loosing the cursor position * * @return \SplFileObject @@ -117,7 +117,7 @@ class Writer extends AbstractCsv } /** - * The destructor + * {@inheritdoc} */ public function __destruct() { |