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