Skip to content

Commit b0a28a0

Browse files
author
Paul
committed
Changed CollectionMapper to map any expression type instead of just Mappings.
1 parent 9722621 commit b0a28a0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/CollectionMapper.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
<?php
22
namespace ScriptFUSION\Mapper;
33

4+
use ScriptFUSION\Mapper\Strategy\Strategy;
5+
46
/**
57
* Maps collections of records.
68
*/
79
class CollectionMapper extends Mapper
810
{
911
/**
1012
* @param \Iterator $collection
11-
* @param Mapping|null $mapping
13+
* @param Strategy|Mapping|array|mixed $expression Expression.
1214
* @param mixed $context
1315
*
1416
* @return \Generator
1517
*
1618
* @throws InvalidRecordException A record in the specified collection was not an array type.
1719
*/
18-
public function mapCollection(\Iterator $collection, Mapping $mapping = null, $context = null)
20+
public function mapCollection(\Iterator $collection, $expression = null, $context = null)
1921
{
2022
foreach ($collection as $key => $record) {
2123
if (!is_array($record)) {
2224
throw new InvalidRecordException('Record must be an array.');
2325
}
2426

25-
yield $key => $mapping
26-
? $this->mapMapping($record, $mapping, $context, $key)
27+
yield $key => $expression !== null
28+
? $this->mapMapping($record, $expression, $context, $key)
2729
: $record;
2830
}
2931
}

0 commit comments

Comments
 (0)