| Conditions | 3 |
| Paths | 3 |
| Total Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | public function denormalize(array $data, APIResponse $response): APIResponse |
||
| 15 | { |
||
| 16 | if ($response instanceof CarbonMonoxide) { |
||
| 17 | $response->time = $this->getValue('time', $data, \DateTimeInterface::class); |
||
| 18 | |||
| 19 | $location = new GeographicCoordinates(); |
||
| 20 | $location->latitude = $this->getData('latitude', $data['location']); |
||
| 21 | $location->longitude = $this->getData('longitude', $data['location']); |
||
| 22 | |||
| 23 | $response->location = $location; |
||
| 24 | |||
| 25 | $polutions = []; |
||
| 26 | foreach ($data['data'] as $datum) { |
||
| 27 | $pollution = new AirPollution(); |
||
| 28 | $pollution->precision = $datum['precision']; |
||
| 29 | $pollution->pressure = $datum['pressure']; |
||
| 30 | $pollution->value = $datum['value']; |
||
| 31 | |||
| 32 | $polutions[] = $pollution; |
||
| 33 | } |
||
| 34 | |||
| 35 | $response->data = $polutions; |
||
| 36 | |||
| 37 | return $response; |
||
| 38 | } |
||
| 39 | |||
| 40 | return $response; |
||
| 41 | } |
||
| 42 | } |
||
| 43 |