diff --git a/README.md b/README.md index 70ac274d..8b28e75c 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ $writer = Writer::createFromString('john,doe,john.doe@example.com'); Both classes constructors take one optional parameter `$open_mode` representing the file open mode used by the PHP [fopen](http://php.net/manual/en/function.fopen.php) function. * The `Bakame\Csv\Writer` `$open_mode` default value is `w`. -* The `Bakame\Csv\Reader` `$open_mode` default value is `r`, and **no other value is possible**. So you don't need to explicitly set it. +* The `Bakame\Csv\Reader` `$open_mode` default value is `r`. The static method `createFromString` is to be use if your data is a string. This method takes no optional `$open_mode` parameter. diff --git a/src/AbstractCsv.php b/src/AbstractCsv.php index 614f5c5e..6c1b258b 100644 --- a/src/AbstractCsv.php +++ b/src/AbstractCsv.php @@ -96,13 +96,6 @@ class AbstractCsv implements JsonSerializable, IteratorAggregate */ protected $encoding = 'UTF-8'; - /** - * Open mode available flag - * - * @var array - */ - protected $available_open_mode = ['r', 'r+', 'w', 'w+', 'x', 'x+', 'a', 'a+', 'c', 'c+']; - /** * The constructor * @@ -177,13 +170,6 @@ protected function fetchFile($path, $open_mode) return $path; } $open_mode = strtolower($open_mode); - if (! in_array($open_mode, $this->available_open_mode)) { - throw new InvalidArgumentException( - 'Invalid `$open_mode` value. Available values are : "' - .implode('", "', $this->available_open_mode).'"' - ); - } - if ($path instanceof SplFileInfo) { return $path->openFile($open_mode); } elseif (is_string($path)) { diff --git a/src/Reader.php b/src/Reader.php index f837598c..8d82c031 100644 --- a/src/Reader.php +++ b/src/Reader.php @@ -51,11 +51,6 @@ class Reader extends AbstractCsv */ use IteratorQuery; - /** - * {@inheritdoc} - */ - protected $available_open_mode = ['r']; - /** * Intelligent Array Combine * diff --git a/src/Writer.php b/src/Writer.php index d3e9ed05..c047953b 100644 --- a/src/Writer.php +++ b/src/Writer.php @@ -44,11 +44,6 @@ */ class Writer extends AbstractCsv { - /** - * {@inheritdoc} - */ - protected $available_open_mode = ['r+', 'w', 'w+', 'x', 'x+', 'a', 'a+', 'c', 'c+']; - /** * {@inheritdoc} */ diff --git a/test/WriterTest.php b/test/WriterTest.php index ccd45cda..3b4a39db 100644 --- a/test/WriterTest.php +++ b/test/WriterTest.php @@ -22,14 +22,6 @@ public function setUp() $this->csv = new Writer(new SplTempFileObject); } - /** - * @expectedException InvalidArgumentException - */ - public function testConstructorWithWrongOpenMode() - { - new Writer('foo.csv', 'r'); - } - public function testInsert() { $expected = [ diff --git a/test/foo.csv b/test/foo.csv index 4307de42..0c85eae9 100644 --- a/test/foo.csv +++ b/test/foo.csv @@ -1,2 +1 @@ -1,2,3 "john","doe","john.doe@example.com" \ No newline at end of file