summaryrefslogtreecommitdiffstats
path: root/src/Modifier/QueryFilter.php
diff options
context:
space:
mode:
authorIgnace Nyamagana Butera <nyamsprod@gmail.com>2015-06-04 09:38:51 +0200
committerIgnace Nyamagana Butera <nyamsprod@gmail.com>2015-06-04 12:26:43 +0200
commitc26e80e9584023cc2268cc0405a00880fe931148 (patch)
tree76a70dd9ecf54b5849a9f2603f801dbb3dd32db9 /src/Modifier/QueryFilter.php
parentca5242603b75a9557c675e34fd70a8cb32d42465 (diff)
downloadcsv-c26e80e9584023cc2268cc0405a00880fe931148.zip
csv-c26e80e9584023cc2268cc0405a00880fe931148.tar.gz
csv-c26e80e9584023cc2268cc0405a00880fe931148.tar.bz2
Resolve issue #102
The enclosure character should also be stripped when The BOM character is removed to properly output CSV content
Diffstat (limited to 'src/Modifier/QueryFilter.php')
-rw-r--r--src/Modifier/QueryFilter.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/Modifier/QueryFilter.php b/src/Modifier/QueryFilter.php
index 03beb52..547f6f2 100644
--- a/src/Modifier/QueryFilter.php
+++ b/src/Modifier/QueryFilter.php
@@ -89,6 +89,11 @@ trait QueryFilter
}
/**
+ * {@inheritdoc}
+ */
+ abstract public function getInputBom();
+
+ /**
* Set LimitIterator Offset
*
* @param $offset
@@ -255,6 +260,11 @@ trait QueryFilter
return new MapIterator($iterator, function ($row, $index) use ($bom) {
if (0 == $index) {
$row[0] = mb_substr($row[0], mb_strlen($bom));
+ $enclosure = $this->getEnclosure();
+ //enclosure should be remove when a BOM sequence is stripped
+ if ($row[0][0] === $enclosure && mb_substr($row[0], -1, 1) == $enclosure) {
+ $row[0] = mb_substr($row[0], 1, -1);
+ }
}
return $row;
@@ -262,11 +272,9 @@ trait QueryFilter
}
/**
- * Returns the BOM sequence of the given CSV
- *
- * @return string
+ * {@inheritdoc}
*/
- abstract public function getInputBom();
+ abstract public function getEnclosure();
/**
* Filter the Iterator