From d9f8b338a55a635407eae732a4cc0a27f328280c Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Sun, 4 Jan 2015 01:43:10 -0500 Subject: [PATCH] various improvements --- .gitignore | 2 -- README.md | 15 +++++++-------- src/Goodby/CSV/Export/Protocol/.gitkeep | 0 src/Goodby/CSV/Export/Standard/Exporter.php | 2 -- src/Goodby/CSV/Export/Standard/ExporterConfig.php | 3 ++- .../Exception/CsvFileNotFoundException.php | 2 +- src/Goodby/CSV/Import/Standard/Interpreter.php | 1 - .../CSV/Import/Tests/Protocol/InterpreterTest.php | 11 ++++++----- .../CSV/Import/Tests/Protocol/LexerTest.php | 5 +++-- .../CSV/Import/Tests/Standard/Join/LexerTest.php | 2 -- .../Standard/Join/Observer/PdoObserverTest.php | 1 - .../Tests/Standard/SandboxDirectoryManager.php | 2 +- 12 files changed, 20 insertions(+), 26 deletions(-) delete mode 100644 src/Goodby/CSV/Export/Protocol/.gitkeep diff --git a/.gitignore b/.gitignore index b315d8e..d19c3e8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -.DS_Store -/.idea .phpmake /vendor /composer.phar diff --git a/README.md b/README.md index de7b6b3..19a8ee3 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Goodby CSV is fully unit-tested. The library is stable and ready to be used in l Install composer in your project: -``` +```bash curl -s http://getcomposer.org/installer | php ``` @@ -60,7 +60,7 @@ Create a `composer.json` file in your project root: Install via composer: -``` +```bash php composer.phar install ``` @@ -130,7 +130,7 @@ $lexer->parse('rough.csv', $interpreter); user.csv: -``` +```csv 1,alice,alice@example.com 2,bob,bob@example.com 3,carol,carol@eample.com @@ -155,14 +155,13 @@ $interpreter->addObserver(function(array $columns) use ($pdo) { }); $lexer->parse('user.csv', $interpreter); - ``` ### Import from TSV(tab separated values) to array temperature.tsv: -``` +```csv 9 Tokyo 27 Singapore -5 Seoul @@ -302,7 +301,7 @@ We works under test driven development. Checkout master source code from github: -``` +```bash hub clone goodby/csv ``` @@ -318,10 +317,10 @@ composer.phar install --dev Run phpunit: -``` +```bash ./vendor/bin/phpunit ``` ## Acknowledgement -editing... +Credits are found within composer.json file. diff --git a/src/Goodby/CSV/Export/Protocol/.gitkeep b/src/Goodby/CSV/Export/Protocol/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/Goodby/CSV/Export/Standard/Exporter.php b/src/Goodby/CSV/Export/Standard/Exporter.php index 0c4e419..125703a 100644 --- a/src/Goodby/CSV/Export/Standard/Exporter.php +++ b/src/Goodby/CSV/Export/Standard/Exporter.php @@ -4,9 +4,7 @@ use Goodby\CSV\Export\Protocol\ExporterInterface; use Goodby\CSV\Export\Protocol\Exception\IOException; -use Goodby\CSV\Export\Standard\ExporterConfig; use Goodby\CSV\Export\Standard\Exception\StrictViolationException; -use SplFileObject; /** * Standard exporter class diff --git a/src/Goodby/CSV/Export/Standard/ExporterConfig.php b/src/Goodby/CSV/Export/Standard/ExporterConfig.php index b36ebd0..28c8196 100644 --- a/src/Goodby/CSV/Export/Standard/ExporterConfig.php +++ b/src/Goodby/CSV/Export/Standard/ExporterConfig.php @@ -197,12 +197,13 @@ public function getFileMode() /** * Set the column headers. - * @param array $headers + * @param array $columnHeaders * @return ExporterConfig */ public function setColumnHeaders(array $columnHeaders) { $this->columnHeaders = $columnHeaders; + return $this; } diff --git a/src/Goodby/CSV/Import/Protocol/Exception/CsvFileNotFoundException.php b/src/Goodby/CSV/Import/Protocol/Exception/CsvFileNotFoundException.php index 68344e1..669f2d2 100644 --- a/src/Goodby/CSV/Import/Protocol/Exception/CsvFileNotFoundException.php +++ b/src/Goodby/CSV/Import/Protocol/Exception/CsvFileNotFoundException.php @@ -3,7 +3,7 @@ namespace Goodby\CSV\Import\Protocol\Exception; /** - * throw if csv file not found + * Throws if csv file not found */ class CsvFileNotFoundException extends \RuntimeException { diff --git a/src/Goodby/CSV/Import/Standard/Interpreter.php b/src/Goodby/CSV/Import/Standard/Interpreter.php index 28974a0..0a49e30 100644 --- a/src/Goodby/CSV/Import/Standard/Interpreter.php +++ b/src/Goodby/CSV/Import/Standard/Interpreter.php @@ -8,7 +8,6 @@ /** * standard interpreter - * */ class Interpreter implements InterpreterInterface { diff --git a/src/Goodby/CSV/Import/Tests/Protocol/InterpreterTest.php b/src/Goodby/CSV/Import/Tests/Protocol/InterpreterTest.php index 43fd083..a570375 100644 --- a/src/Goodby/CSV/Import/Tests/Protocol/InterpreterTest.php +++ b/src/Goodby/CSV/Import/Tests/Protocol/InterpreterTest.php @@ -6,7 +6,6 @@ /** * unit test for Interface of the Interpreter - * */ class InterpreterTest extends \PHPUnit_Framework_TestCase { @@ -17,8 +16,9 @@ public function testInterpreterInterface() $interpreter = $this->getMock('\Goodby\CSV\Import\Protocol\InterpreterInterface'); $interpreter->expects($this->once()) - ->method('interpret') - ->with($this->identicalTo($line)); + ->method('interpret') + ->with($this->identicalTo($line)) + ; $interpreter->interpret($line); } @@ -31,8 +31,9 @@ public function testInterpreterInterfaceWillThrownInvalidLexicalException() $interpreter = $this->getMock('\Goodby\CSV\Import\Protocol\InterpreterInterface'); $interpreter->expects($this->once()) - ->method('interpret') - ->will($this->throwException(new InvalidLexicalException())); + ->method('interpret') + ->will($this->throwException(new InvalidLexicalException())) + ; $line = "INVALID LEXICAL"; diff --git a/src/Goodby/CSV/Import/Tests/Protocol/LexerTest.php b/src/Goodby/CSV/Import/Tests/Protocol/LexerTest.php index 718bed9..82fa0a0 100644 --- a/src/Goodby/CSV/Import/Tests/Protocol/LexerTest.php +++ b/src/Goodby/CSV/Import/Tests/Protocol/LexerTest.php @@ -32,8 +32,9 @@ public function testCsvFileNotFound() $path = 'invalid_dummy.csv'; $lexer->shouldReceive('parse') - ->with($path, $interpreter) - ->andThrow('Goodby\CSV\Import\Protocol\Exception\CsvFileNotFoundException'); + ->with($path, $interpreter) + ->andThrow('Goodby\CSV\Import\Protocol\Exception\CsvFileNotFoundException') + ; $lexer->parse($path, $interpreter); } diff --git a/src/Goodby/CSV/Import/Tests/Standard/Join/LexerTest.php b/src/Goodby/CSV/Import/Tests/Standard/Join/LexerTest.php index 647aaf9..8577d1e 100644 --- a/src/Goodby/CSV/Import/Tests/Standard/Join/LexerTest.php +++ b/src/Goodby/CSV/Import/Tests/Standard/Join/LexerTest.php @@ -7,8 +7,6 @@ use Goodby\CSV\Import\Standard\Interpreter; use Goodby\CSV\Import\Standard\LexerConfig; -use Goodby\CSV\Import\Tests\Standard\Join\CSVFiles; - class LexerTest extends \PHPUnit_Framework_TestCase { public function test_shift_jis_CSV() diff --git a/src/Goodby/CSV/Import/Tests/Standard/Join/Observer/PdoObserverTest.php b/src/Goodby/CSV/Import/Tests/Standard/Join/Observer/PdoObserverTest.php index 04d8712..971b07b 100644 --- a/src/Goodby/CSV/Import/Tests/Standard/Join/Observer/PdoObserverTest.php +++ b/src/Goodby/CSV/Import/Tests/Standard/Join/Observer/PdoObserverTest.php @@ -11,7 +11,6 @@ /** * unit test for pdo observer - * */ class PdoObserverTest extends \PHPUnit_Framework_TestCase { diff --git a/src/Goodby/CSV/Import/Tests/Standard/SandboxDirectoryManager.php b/src/Goodby/CSV/Import/Tests/Standard/SandboxDirectoryManager.php index 8ea8fd9..329e04f 100644 --- a/src/Goodby/CSV/Import/Tests/Standard/SandboxDirectoryManager.php +++ b/src/Goodby/CSV/Import/Tests/Standard/SandboxDirectoryManager.php @@ -3,7 +3,7 @@ namespace Goodby\CSV\Import\Tests\Standard; /** - * 結合テストでファイルシステムと結合するときに使うサンドボックスディレクトリを管理する + * Managing sandbox directory to use when joining with the file system for tests */ class SandboxDirectoryManager {