1 | <?php |
||
13 | trait Mappers |
||
14 | { |
||
15 | /** |
||
16 | * @var Mapper[] list of Mappers |
||
17 | */ |
||
18 | protected $mappers = []; |
||
19 | |||
20 | /** |
||
21 | * Append a Mapper instance to apply when each batch of a record-set is fetched. |
||
22 | * |
||
23 | * @param Mapper $mapper |
||
24 | * |
||
25 | * @see mapRecords() to map an anonymous function against every record |
||
26 | * @see mapBatches() to map an anonymous function against each batch of records |
||
27 | * |
||
28 | * @return $this |
||
29 | */ |
||
30 | public function map(Mapper $mapper) |
||
36 | |||
37 | /** |
||
38 | * Map an anonymous function against every record. |
||
39 | * |
||
40 | * @param callable $mapper function (mixed $record) : mixed |
||
41 | * |
||
42 | * @see mapBatches() to map an anonymous function against each batch of records |
||
43 | * |
||
44 | * @return $this |
||
45 | */ |
||
46 | 1 | public function mapRecords(callable $mapper) |
|
52 | |||
53 | /** |
||
54 | * Map an anonymous function against each batch of records. |
||
55 | * |
||
56 | * @param callable $mapper function (array $record_set) : array |
||
57 | * |
||
58 | * @see mapRecords() to map an anonymous function against every record |
||
59 | * |
||
60 | * @return $this |
||
61 | */ |
||
62 | public function mapBatches(callable $mapper) |
||
68 | } |
||
69 |