| Conditions | 5 |
| Paths | 5 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 5.2742 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 35 | 1 | public function map(array $record_set): array|Traversable |
|
| 36 | { |
||
| 37 | 1 | foreach ($record_set as $index => $record) { |
|
| 38 | 1 | if (! is_array($record)) { |
|
| 39 | throw new UnexpectedValueException("unexpected record type: " . gettype($record)); |
||
| 40 | } |
||
| 41 | |||
| 42 | 1 | foreach ($this->types as $name => $type) { |
|
| 43 | 1 | if (! array_key_exists($name, $record)) { |
|
| 44 | throw new OutOfBoundsException("undefined record field: {$name}"); |
||
| 45 | } |
||
| 46 | |||
| 47 | 1 | $record[$name] = $type->convertToPHP($record[$name]); |
|
| 48 | } |
||
| 49 | |||
| 50 | 1 | yield $index => $record; |
|
| 51 | } |
||
| 54 |