Skip to content

Commit 552ac7e

Browse files
authored
Merge pull request #2 from Shipu/master
introduce new method `map`
2 parents 994173b + debfec1 commit 552ac7e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/QueryEngine.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,28 @@ public function transform(callable $fn)
733733

734734
return $this;
735735
}
736+
737+
738+
/**
739+
* map prepared data by using callable function for each entity
740+
*
741+
* @param callable $fn
742+
* @return object|array
743+
* @throws ConditionNotAllowedException
744+
*/
745+
public function map(callable $fn)
746+
{
747+
$this->prepare();
748+
$data = [];
749+
750+
foreach ($this->_map as $key => $val) {
751+
$data[$key] = $fn($val);
752+
}
753+
754+
$this->_map = $data;
755+
756+
return $this;
757+
}
736758

737759
/**
738760
* pipe send output in next pipe

0 commit comments

Comments
 (0)