diff options
author | ignace nyamagana butera <nyamsprod@gmail.com> | 2015-11-27 12:27:59 +0100 |
---|---|---|
committer | ignace nyamagana butera <nyamsprod@gmail.com> | 2015-11-27 12:27:59 +0100 |
commit | d8a5e53020e0fc7629c63c57ff6563272595ffca (patch) | |
tree | 871c3df0166c5a6b4b7e82b6ee5a63e6e2fab4cd | |
parent | 88647661e411ac311330a554c97b910309248681 (diff) | |
download | csv-d8a5e53020e0fc7629c63c57ff6563272595ffca.zip csv-d8a5e53020e0fc7629c63c57ff6563272595ffca.tar.gz csv-d8a5e53020e0fc7629c63c57ff6563272595ffca.tar.bz2 |
Improve Inner Filter application
-rw-r--r-- | src/AbstractCsv.php | 2 | ||||
-rw-r--r-- | src/Reader.php | 6 |
2 files changed, 3 insertions, 5 deletions
diff --git a/src/AbstractCsv.php b/src/AbstractCsv.php index 27ba772..5ab72a1 100644 --- a/src/AbstractCsv.php +++ b/src/AbstractCsv.php @@ -142,7 +142,7 @@ abstract class AbstractCsv implements JsonSerializable, IteratorAggregate */ protected function getCsvIterator() { - $this->addFilter(function ($row) { + array_unshift($this->iterator_filters, function ($row) { return is_array($row) && $row != [null]; }); $iterator = $this->getIterator(); diff --git a/src/Reader.php b/src/Reader.php index 5cd385e..4aad520 100644 --- a/src/Reader.php +++ b/src/Reader.php @@ -42,9 +42,7 @@ class Reader extends AbstractCsv */ public function fetch(callable $callable = null) { - $iterator = $this->getCsvIterator(); - - return $this->applyCallable($iterator, $callable); + return $this->applyCallable($this->getCsvIterator(), $callable); } /** @@ -264,7 +262,7 @@ class Reader extends AbstractCsv $keys = $this->getRow($offset_or_keys); $this->assertValidAssocKeys($keys); $filterOutRow = function ($row, $rowIndex) use ($offset_or_keys) { - return is_array($row) && $rowIndex != $offset_or_keys; + return $rowIndex != $offset_or_keys; }; $this->addFilter($filterOutRow); |