diff options
-rw-r--r-- | CHANGELOG.md | 9 | ||||
-rw-r--r-- | src/AbstractCsv.php | 16 | ||||
-rw-r--r-- | test/CsvTest.php | 16 |
3 files changed, 21 insertions, 20 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 864f43d..b8b0ddb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,11 @@ All Notable changes to `League\Csv` will be documented in this file ## 6.3.0 - XXXX-XX-XX ### Added -- `AbstractCSV::setBOMOnOutput` -- `AbstractCSV::getBOMOnOutput` -- `AbstractCSV::getBOMOnInput` - to manage BOM character with CSV. +- `AbstractCSV::setOutputBOM` +- `AbstractCSV::getOutputBOM` +- `AbstractCSV::getInputBOM` + +to manage BOM character with CSV. ## 6.2.0 - 2014-12-12 diff --git a/src/AbstractCsv.php b/src/AbstractCsv.php index f3735bf..66c60da 100644 --- a/src/AbstractCsv.php +++ b/src/AbstractCsv.php @@ -85,7 +85,7 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate * BOM sequence for Outputting the CSV * @var string */ - protected $bom_sequence; + protected $bom; /** * Csv Controls Trait @@ -341,7 +341,7 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate * * @return string */ - public function getBOMOnInput() + public function getInputBOM() { $bom = [self::BOM_UTF8, self::BOM_UTF16_BE, self::BOM_UTF16_LE, self::BOM_UTF32_BE, self::BOM_UTF32_LE]; $csv = $this->getIterator(); @@ -362,15 +362,15 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate * * @return static */ - public function setBOMOnOutput($str = null) + public function setOutputBOM($str = null) { if (is_null($str)) { - $this->bom_sequence = $str; + $this->bom = $str; return $this; } $str = (string) $str; $str = trim($str); - $this->bom_sequence = $str; + $this->bom = $str; return $this; } @@ -380,9 +380,9 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate * * @return string */ - public function getBOMOnOutput() + public function getOutputBOM() { - return $this->bom_sequence; + return $this->bom; } /** @@ -403,7 +403,7 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate header("Content-Disposition: attachment; filename=\"$fname\"; filename*=UTF-8' '".rawurlencode($fname)); } //@codeCoverageIgnoreEnd - echo $this->bom_sequence; + echo $this->bom; $iterator->rewind(); $iterator->fpassthru(); } diff --git a/test/CsvTest.php b/test/CsvTest.php index 095b1ea..9d9d620 100644 --- a/test/CsvTest.php +++ b/test/CsvTest.php @@ -107,16 +107,16 @@ class CsvTest extends PHPUnit_Framework_TestCase public function testBOMSettings() { - $this->assertNull($this->csv->getBOMOnOutput()); - $this->csv->setBOMOnOutput(Reader::BOM_UTF8); - $this->assertSame(Reader::BOM_UTF8, $this->csv->getBOMOnOutput()); - $this->csv->setBOMOnOutput(); - $this->assertNull($this->csv->getBOMOnOutput()); + $this->assertNull($this->csv->getOutputBOM()); + $this->csv->setOutputBOM(Reader::BOM_UTF8); + $this->assertSame(Reader::BOM_UTF8, $this->csv->getOutputBOM()); + $this->csv->setOutputBOM(); + $this->assertNull($this->csv->getOutputBOM()); } public function testAddBOMSequences() { - $this->csv->setBOMOnOutput(Reader::BOM_UTF8); + $this->csv->setOutputBOM(Reader::BOM_UTF8); $expected = chr(239).chr(187).chr(191)."john,doe,john.doe@example.com".PHP_EOL ."jane,doe,jane.doe@example.com".PHP_EOL; $this->assertSame($expected, $this->csv->__toString()); @@ -127,7 +127,7 @@ class CsvTest extends PHPUnit_Framework_TestCase $expected = "john,doe,john.doe@example.com".PHP_EOL ."jane,doe,jane.doe@example.com".PHP_EOL; $reader = Reader::createFromString($expected); - $this->assertEmpty($reader->getBomOnInput()); + $this->assertEmpty($reader->getInputBOM()); } public function testGetBomOnInputWithBOM() @@ -135,7 +135,7 @@ class CsvTest extends PHPUnit_Framework_TestCase $expected = "\x00\x00\xFE\xFFjohn,doe,john.doe@example.com".PHP_EOL ."jane,doe,jane.doe@example.com".PHP_EOL; $reader = Reader::createFromString($expected); - $this->assertSame(Reader::BOM_UTF32_BE, $reader->getBomOnInput()); + $this->assertSame(Reader::BOM_UTF32_BE, $reader->getInputBOM()); } /** |