Skip to content

Commit

Permalink
remove validation resolves #14
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Feb 22, 2014
1 parent f4c2216 commit 5af5391
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ $writer = Writer::createFromString('john,doe,[email protected]');

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.

Expand Down
14 changes: 0 additions & 14 deletions src/AbstractCsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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)) {
Expand Down
5 changes: 0 additions & 5 deletions src/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ class Reader extends AbstractCsv
*/
use IteratorQuery;

/**
* {@inheritdoc}
*/
protected $available_open_mode = ['r'];

/**
* Intelligent Array Combine
*
Expand Down
5 changes: 0 additions & 5 deletions src/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@
*/
class Writer extends AbstractCsv
{
/**
* {@inheritdoc}
*/
protected $available_open_mode = ['r+', 'w', 'w+', 'x', 'x+', 'a', 'a+', 'c', 'c+'];

/**
* {@inheritdoc}
*/
Expand Down
8 changes: 0 additions & 8 deletions test/WriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
1 change: 0 additions & 1 deletion test/foo.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
1,2,3
"john","doe","[email protected]"

0 comments on commit 5af5391

Please sign in to comment.