| Total Complexity | 3 | 
| Total Lines | 54 | 
| Duplicated Lines | 0 % | 
| Coverage | 33.33% | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php | ||
| 12 | trait Mappers | ||
| 13 | { | ||
| 14 | /** | ||
| 15 | * @var Mapper[] list of Mappers | ||
| 16 | */ | ||
| 17 | protected array $mappers = []; | ||
| 18 | |||
| 19 | /** | ||
| 20 | * Append a Mapper instance to apply when each batch of a record-set is fetched. | ||
| 21 | * | ||
| 22 | * @param Mapper $mapper | ||
| 23 | * | ||
| 24 | * @see mapRecords() to map an anonymous function against every record | ||
| 25 | * @see mapBatches() to map an anonymous function against each batch of records | ||
| 26 | * | ||
| 27 | * @return $this | ||
| 28 | */ | ||
| 29 | public function map(Mapper $mapper): static | ||
| 34 | } | ||
| 35 | |||
| 36 | /** | ||
| 37 | * Map an anonymous function against every record. | ||
| 38 | * | ||
| 39 | * @param callable $mapper function (mixed $record) : mixed | ||
| 40 | * | ||
| 41 | * @see mapBatches() to map an anonymous function against each batch of records | ||
| 42 | * | ||
| 43 | * @return $this | ||
| 44 | */ | ||
| 45 | 1 | public function mapRecords(callable $mapper): static | |
| 46 |     { | ||
| 47 | 1 | $this->mappers[] = new RecordMapper($mapper); | |
| 48 | |||
| 49 | 1 | return $this; | |
| 50 | } | ||
| 51 | |||
| 52 | /** | ||
| 53 | * Map an anonymous function against each batch of records. | ||
| 54 | * | ||
| 55 | * @param callable $mapper function (array $record_set) : array | ||
| 56 | * | ||
| 57 | * @see mapRecords() to map an anonymous function against every record | ||
| 58 | * | ||
| 59 | * @return $this | ||
| 60 | */ | ||
| 61 | public function mapBatches(callable $mapper): static | ||
| 66 | } | ||
| 67 | } | ||
| 68 |