summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/AbstractCsv.php19
-rw-r--r--src/Config/Controls.php25
-rw-r--r--src/Config/Output.php2
-rw-r--r--test/CsvTest.php4
4 files changed, 28 insertions, 22 deletions
diff --git a/src/AbstractCsv.php b/src/AbstractCsv.php
index 79a8355..509f414 100644
--- a/src/AbstractCsv.php
+++ b/src/AbstractCsv.php
@@ -290,25 +290,6 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate
}
/**
- * Returns the BOM sequence of the given CSV
- *
- * @return string
- */
- public function detectInputBOM()
- {
- $bom = [self::BOM_UTF8, self::BOM_UTF16_BE, self::BOM_UTF16_LE, self::BOM_UTF32_BE, self::BOM_UTF32_LE];
- $csv = $this->getIterator();
- $csv->rewind();
- $line = $csv->fgets();
-
- $res = array_filter($bom, function ($sequence) use ($line) {
- return strpos($line, $sequence) === 0;
- });
-
- return array_shift($res);
- }
-
- /**
* Validate a variable to be stringable
*
* @param object|string $str
diff --git a/src/Config/Controls.php b/src/Config/Controls.php
index e98058d..1601e88 100644
--- a/src/Config/Controls.php
+++ b/src/Config/Controls.php
@@ -231,4 +231,29 @@ trait Controls
{
return $this->flags;
}
+
+ /**
+ * Returns the BOM sequence of the given CSV
+ *
+ * @return string
+ */
+ 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();
+ $csv->rewind();
+ $line = $csv->fgets();
+
+ $res = array_filter($bom, function ($sequence) use ($line) {
+ return strpos($line, $sequence) === 0;
+ });
+
+ return array_shift($res);
+ }
}
diff --git a/src/Config/Output.php b/src/Config/Output.php
index 6eab996..3c13352 100644
--- a/src/Config/Output.php
+++ b/src/Config/Output.php
@@ -124,7 +124,7 @@ trait Output
{
$iterator = $this->getIterator();
//@codeCoverageIgnoreStart
- if (! is_null($filename) && League\Csv\AbstractCsv::isValidString($filename)) {
+ if (! is_null($filename) && self::isValidString($filename)) {
$fname = (string) $filename;
$fname = trim($fname);
$fname = filter_var($fname, FILTER_UNSAFE_RAW, ['flags' => FILTER_FLAG_STRIP_LOW]);
diff --git a/test/CsvTest.php b/test/CsvTest.php
index 9d3215a..9d9d620 100644
--- a/test/CsvTest.php
+++ b/test/CsvTest.php
@@ -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->detectInputBOM());
+ $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->detectInputBOM());
+ $this->assertSame(Reader::BOM_UTF32_BE, $reader->getInputBOM());
}
/**