Skip to content

Commit

Permalink
Merge pull request #4 from phillipsdata/factory-set-file-openmode
Browse files Browse the repository at this point in the history
Updated the Factory to support setting the file open mode for the rea…
  • Loading branch information
clphillips committed Mar 4, 2016
2 parents b72e5ef + 1e88989 commit 4adf31f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ class Factory
* @param string $delimiter
* @param string $enclosure
* @param string $escape
* @param string $openMode
* @return \PhillipsData\Csv\Reader
*/
public static function writer(
$filename,
$delimiter = ',',
$enclosure = '"',
$escape = '\\'
$escape = '\\',
$openMode = 'w'
) {
$file = static::fileObject($filename, 'w');
$file = static::fileObject($filename, $openMode);
$file->setCsvControl($delimiter, $enclosure, $escape);
$writer = Writer::output($file);

Expand All @@ -38,16 +40,18 @@ public static function writer(
* @param string $enclosure
* @param string $escape
* @param bool $withHeader
* @param string $openMode
* @return \PhillipsData\Csv\Reader
*/
public static function reader(
$filename,
$delimiter = ',',
$enclosure = '"',
$escape = '\\',
$withHeader = true
$withHeader = true,
$openMode = 'r'
) {
$file = static::fileObject($filename);
$file = static::fileObject($filename, $openMode);
$file->setCsvControl($delimiter, $enclosure, $escape);
$reader = Reader::input($file, $withHeader);

Expand Down

0 comments on commit 4adf31f

Please sign in to comment.