@@ -107,7 +107,10 @@ public function __construct($data, $units)
107
107
$ this ->temperature = new Temperature (new Unit ($ data ->temperature ['value ' ], $ data ->temperature ['unit ' ]), new Unit ($ data ->temperature ['min ' ], $ data ->temperature ['unit ' ]), new Unit ($ data ->temperature ['max ' ], $ data ->temperature ['unit ' ]));
108
108
$ this ->humidity = new Unit ($ data ->humidity ['value ' ], $ data ->humidity ['unit ' ]);
109
109
$ this ->pressure = new Unit ($ data ->pressure ['value ' ], $ data ->pressure ['unit ' ]);
110
- $ this ->wind = new Wind (new Unit ($ data ->wind ->speed ['value ' ], $ windSpeedUnit , $ data ->wind ->speed ['name ' ]), new Unit ($ data ->wind ->direction ['value ' ], $ data ->wind ->direction ['code ' ], $ data ->wind ->direction ['name ' ]));
110
+ $ this ->wind = new Wind (
111
+ new Unit ($ data ->wind ->speed ['value ' ], $ windSpeedUnit , $ data ->wind ->speed ['name ' ]),
112
+ property_exists ($ data ->wind , 'direction ' ) ? new Unit ($ data ->wind ->direction ['value ' ], $ data ->wind ->direction ['code ' ], $ data ->wind ->direction ['name ' ]) : null
113
+ );
111
114
$ this ->clouds = new Unit ($ data ->clouds ['value ' ], null , $ data ->clouds ['name ' ]);
112
115
$ this ->precipitation = new Unit ($ data ->precipitation ['value ' ], $ data ->precipitation ['unit ' ], $ data ->precipitation ['mode ' ]);
113
116
$ this ->sun = new Sun (new \DateTime ($ data ->city ->sun ['rise ' ], $ utctz ), new \DateTime ($ data ->city ->sun ['set ' ], $ utctz ));
@@ -118,7 +121,10 @@ public function __construct($data, $units)
118
121
$ this ->temperature = new Temperature (new Unit ($ data ->main ->temp , $ units ), new Unit ($ data ->main ->temp_min , $ units ), new Unit ($ data ->main ->temp_max , $ units ));
119
122
$ this ->humidity = new Unit ($ data ->main ->humidity , '% ' );
120
123
$ this ->pressure = new Unit ($ data ->main ->pressure , 'hPa ' );
121
- $ this ->wind = new Wind (new Unit ($ data ->wind ->speed , $ windSpeedUnit ), new Unit ($ data ->wind ->deg ));
124
+ $ this ->wind = new Wind (
125
+ new Unit ($ data ->wind ->speed , $ windSpeedUnit ),
126
+ property_exists ($ data ->wind , 'deg ' ) ? new Unit ($ data ->wind ->deg ) : null
127
+ );
122
128
$ this ->clouds = new Unit ($ data ->clouds ->all , '% ' );
123
129
124
130
// the rain field is not always present in the JSON response
0 commit comments