| Conditions | 5 |
| Paths | 5 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 44 | public function transform($object, $targetClass) |
||
| 45 | { |
||
| 46 | if (count($object) == 0) { |
||
| 47 | return []; |
||
| 48 | } |
||
| 49 | |||
| 50 | $modelTransformer = $this->modelTransformer->findSupportedModelTransformer(reset($object), $targetClass); |
||
| 51 | if (!$modelTransformer) { |
||
| 52 | throw new UnsupportedTransformationException(); |
||
| 53 | } |
||
| 54 | |||
| 55 | $elements = []; |
||
| 56 | foreach ($object as $element) { |
||
| 57 | if (!$this->modelTransformer->supports($element, $targetClass)) { |
||
| 58 | throw new UnsupportedTransformationException(); |
||
| 59 | } |
||
| 60 | |||
| 61 | $elements[] = $modelTransformer->transform($element, $targetClass); |
||
| 62 | } |
||
| 63 | |||
| 64 | return $elements; |
||
| 65 | } |
||
| 66 | } |
||
| 67 |