@@ -310,9 +310,13 @@ public function getForecastUVIndex($lat, $lon, $cnt = 8)
310
310
{
311
311
$ answer = $ this ->getRawUVIndexData ('forecast ' , $ lat , $ lon , $ cnt );
312
312
$ data = $ this ->parseJson ($ answer );
313
-
314
- return array_map (function ($ entry ) {
315
- return new UVIndex ($ entry );
313
+ if (is_object ($ data )) {
314
+ $ lat = $ data ->coord ->lat ;
315
+ $ lon = $ data ->coord ->lon ;
316
+ $ data = $ data ->list ;
317
+ }
318
+ return array_map (function ($ entry ) use ($ lat , $ lon ) {
319
+ return new UVIndex ($ entry , $ lat , $ lon );
316
320
}, $ data );
317
321
}
318
322
@@ -335,9 +339,13 @@ public function getHistoricUVIndex($lat, $lon, $start, $end)
335
339
{
336
340
$ answer = $ this ->getRawUVIndexData ('historic ' , $ lat , $ lon , null , $ start , $ end );
337
341
$ data = $ this ->parseJson ($ answer );
338
-
339
- return array_map (function ($ entry ) {
340
- return new UVIndex ($ entry );
342
+ if (is_object ($ data )) {
343
+ $ lat = $ data ->coord ->lat ;
344
+ $ lon = $ data ->coord ->lon ;
345
+ $ data = $ data ->list ;
346
+ }
347
+ return array_map (function ($ entry ) use ($ lat , $ lon ) {
348
+ return new UVIndex ($ entry , $ lat , $ lon );
341
349
}, $ data );
342
350
}
343
351
0 commit comments