From 44839960b1ef79e9587ffd1944723cb60a02bc66 Mon Sep 17 00:00:00 2001 From: David ALIBERT Date: Wed, 22 Jun 2016 19:13:43 +0200 Subject: [PATCH] Modifying ArrayMapper behavior : We replaced the array_map() process with a foreach, to continue the iteration if the pick of a PickerInterface is returning false. This allows to only have the wanted final values in the returning array of the getData() method instead of, for example, have null values or false values in this array. --- src/Mappers/ArrayMapper.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Mappers/ArrayMapper.php b/src/Mappers/ArrayMapper.php index 9b0413f..c87afa4 100644 --- a/src/Mappers/ArrayMapper.php +++ b/src/Mappers/ArrayMapper.php @@ -51,9 +51,12 @@ public function getData() { $data = []; foreach ($this->dataSource->getData() as $row) { - $data [] = array_map(function (PickerInterface $picker) use ($row) { - return $picker->pick(new Row($row)); - }, $this->matchers); + foreach ($this->matchers as $picker){ + if (!($return = $picker->pick(new Row($row)))) { + continue; + } + $data [] = $return; + } } return $data; }