Skip to content

Commit

Permalink
Rename method to CharserConverter::addBOMSkippingTo
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Feb 14, 2023
1 parent c1af9e8 commit db12286
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ All Notable changes to `Csv` will be documented in this file
- `TabularDataWriter` interface to represent how to write to a tabular data document.
- `TabularDataReader::first` to replace `TabularDataReader::fetchOne`
- `TabularDataReader::nth` to replace `TabularDataReader::fetchOne`
- `CharsetConverter::skipBOM` to improve BOM skipping see [bug #483](https://github.com/thephpleague/csv/issues/483)
- `CharsetConverter::addBOMSkippingTo` to improve BOM skipping see [bug #483](https://github.com/thephpleague/csv/issues/483)

### Deprecated

Expand Down
4 changes: 2 additions & 2 deletions docs/9.0/interoperability/encoding.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ use League\Csv\CharsetConverter;
$input = Reader::BOM_UTF16_BE."john,doe,[email protected]\njane,doe,[email protected]\n";
$document = Reader::createFromString($input);
$document->includeInputBOM(); // de-activate the default skipping mechanism
CharsetConverter::allowBOMSkipping($document);
var_dump(iterator_to_array($document));
CharsetConverter::addBOMSkippingTo($document);
var_dump([...$document]);
// returns the document content without the skipped BOM sequence
// [
// ['john', 'doe', '[email protected]'],
Expand Down
2 changes: 1 addition & 1 deletion src/CharsetConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CharsetConverter extends php_user_filter
/**
* Static method to add the stream filter to a {@link Reader} object to handle BOM skipping.
*/
public static function allowBOMSkipping(Reader $document, string $output_encoding = 'UTF-8'): Reader
public static function addBOMSkippingTo(Reader $document, string $output_encoding = 'UTF-8'): Reader
{
self::register();

Expand Down
8 changes: 4 additions & 4 deletions src/CharsetConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function testItDoesNotChangeTheCSVContentIfNoBOMSequenceIsFound(): void
end"
CSV;
$reader = Reader::createFromString($data);
CharsetConverter::allowBOMSkipping($reader);
CharsetConverter::addBOMSkippingTo($reader);
$reader->includeInputBOM();

self::assertSame(
Expand All @@ -179,7 +179,7 @@ public static function testItSkipBOMSequenceBeforeConsumingTheCSVStream(string $
CSV;
$reader = Reader::createFromString($sequence.$data);
$reader->includeInputBOM();
CharsetConverter::allowBOMSkipping($reader);
CharsetConverter::addBOMSkippingTo($reader);

self::assertSame(
[['start
Expand All @@ -197,7 +197,7 @@ public function testItOnlySkipOnceTheBOMSequenceBeforeConsumingTheCSVStreamOnMul
CSV;
$reader = Reader::createFromString($sequence.$data);
$reader->includeInputBOM();
CharsetConverter::allowBOMSkipping($reader);
CharsetConverter::addBOMSkippingTo($reader);

self::assertSame(
[[$sequence.'start
Expand All @@ -210,7 +210,7 @@ public function testItOnlySkipOnceTheBOMSequenceBeforeConsumingTheCSVStreamOnMul
public function testItOnlySkipOnceTheBOMSequenceBeforeConsumingTheCSVStreamOnSingleLine(string $sequence): void
{
$reader = Reader::createFromString($sequence.$sequence.'start,'.$sequence.'end');
CharsetConverter::allowBOMSkipping($reader);
CharsetConverter::addBOMSkippingTo($reader);
$reader->includeInputBOM();

self::assertSame(
Expand Down

0 comments on commit db12286

Please sign in to comment.