Total Complexity | 5 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
15 | class MassSchemator implements MassSchematorInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var SchematorInterface Schemator instance |
||
19 | */ |
||
20 | protected SchematorInterface $schemator; |
||
21 | |||
22 | /** |
||
23 | * MassSchemator constructor. |
||
24 | * @param SchematorInterface $schemator Schemator instance |
||
25 | */ |
||
26 | public function __construct(SchematorInterface $schemator) |
||
27 | { |
||
28 | $this->schemator = $schemator; |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * @inheritDoc |
||
33 | */ |
||
34 | public function generate(iterable $source, array $schema): Generator |
||
35 | { |
||
36 | foreach ($source as $item) { |
||
37 | yield $this->schemator->convert($item, $schema); |
||
38 | } |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @inheritDoc |
||
43 | */ |
||
44 | public function convert(iterable $source, array $schema): array |
||
54 | } |
||
55 | } |
||
56 |