@@ -35,7 +35,7 @@ class OpenWeatherMap
3535 * @var string $weatherUrl The basic api url to fetch weather data from.
3636 */
3737 private $ weatherUrl = "http://api.openweathermap.org/data/2.5/weather? " ;
38-
38+
3939 /**
4040 * @var string $url The basic api url to fetch weekly forecast data from.
4141 */
@@ -101,7 +101,7 @@ public function __construct($fetcher = null, $cacheClass = false, $seconds = 600
101101 if ($ seconds == 0 ) {
102102 $ cacheClass = false ;
103103 }
104-
104+
105105 $ this ->cacheClass = $ cacheClass ;
106106 $ this ->seconds = $ seconds ;
107107 $ this ->fetcher = $ fetcher ;
@@ -156,7 +156,7 @@ public function getWeather($query, $units = 'imperial', $lang = 'en', $appid = '
156156
157157 try {
158158 $ xml = new \SimpleXMLElement ($ answer );
159- } catch (\Exception $ e ) {
159+ } catch (\Exception $ e ) {
160160 // Invalid xml format. This happens in case OpenWeatherMap returns an error.
161161 // OpenWeatherMap always uses json for errors, even if one specifies xml as format.
162162 $ error = json_decode ($ answer , true );
@@ -166,6 +166,7 @@ public function getWeather($query, $units = 'imperial', $lang = 'en', $appid = '
166166 throw new OWMException ('Unknown fatal error: OpenWeatherMap returned the following json object: ' . $ answer );
167167 }
168168 }
169+
169170 return new CurrentWeather ($ xml , $ units );
170171 }
171172
@@ -225,7 +226,7 @@ public function getWeatherForecast($query, $units = 'imperial', $lang = 'en', $a
225226
226227 try {
227228 $ xml = new \SimpleXMLElement ($ answer );
228- } catch (\Exception $ e ) {
229+ } catch (\Exception $ e ) {
229230 // Invalid xml format. This happens in case OpenWeatherMap returns an error.
230231 // OpenWeatherMap always uses json for errors, even if one specifies xml as format.
231232 $ error = json_decode ($ answer , true );
@@ -295,23 +296,23 @@ public function getWeatherHistory($query, \DateTime $start, $endOrCount = 1, $ty
295296
296297 return new WeatherHistory ($ xml , $ query );
297298 }
298-
299+
299300 /**
300301 * @deprecated Use {@link self::getRawWeatherData()} instead.
301302 */
302303 public function getRawData ($ query , $ units = 'imperial ' , $ lang = 'en ' , $ appid = '' , $ mode = 'xml ' )
303304 {
304- return $ this ->getRawWeatherData ($ query , $ units , $ lang , $ appid , $ mode );
305+ return $ this ->getRawWeatherData ($ query , $ units , $ lang , $ appid , $ mode );
305306 }
306-
307+
307308 /**
308309 * Directly returns the xml/json/html string returned by OpenWeatherMap for the current weather.
309310 *
310311 * @param array|int|string $query The place to get weather information for. For possible values see below.
311- * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
312- * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below.
313- * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details.
314- * @param string $mode The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default).
312+ * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
313+ * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below.
314+ * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details.
315+ * @param string $mode The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default).
315316 *
316317 * @return string Returns false on failure and the fetched data in the format you specified on success.
317318 *
@@ -354,10 +355,10 @@ public function getRawWeatherData($query, $units = 'imperial', $lang = 'en', $ap
354355 * Directly returns the xml/json/html string returned by OpenWeatherMap for the hourly forecast.
355356 *
356357 * @param array|int|string $query The place to get weather information for. For possible values see below.
357- * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
358- * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below.
359- * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details.
360- * @param string $mode The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default).
358+ * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
359+ * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below.
360+ * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details.
361+ * @param string $mode The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default).
361362 *
362363 * @return string Returns false on failure and the fetched data in the format you specified on success.
363364 *
@@ -400,10 +401,10 @@ public function getRawHourlyForecastData($query, $units = 'imperial', $lang = 'e
400401 * Directly returns the xml/json/html string returned by OpenWeatherMap for the daily forecast.
401402 *
402403 * @param array|int|string $query The place to get weather information for. For possible values see below.
403- * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
404- * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below.
405- * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details.
406- * @param string $mode The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default).
404+ * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
405+ * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below.
406+ * @param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details.
407+ * @param string $mode The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default).
407408 *
408409 * @return string Returns false on failure and the fetched data in the format you specified on success.
409410 *
@@ -438,7 +439,7 @@ public function getRawHourlyForecastData($query, $units = 'imperial', $lang = 'e
438439 public function getRawDailyForecastData ($ query , $ units = 'imperial ' , $ lang = 'en ' , $ appid = '' , $ mode = 'xml ' )
439440 {
440441 $ url = $ this ->buildUrl ($ query , $ units , $ lang , $ appid , $ mode , $ this ->weatherDailyForecastUrl );
441-
442+
442443 return $ this ->cacheOrFetchResult ('dailyForecast ' , $ query , $ units , $ lang , $ mode , $ url );
443444 }
444445
@@ -449,7 +450,7 @@ public function getRawDailyForecastData($query, $units = 'imperial', $lang = 'en
449450 * @param \DateTime $start The \DateTime object of the date to get the first weather information from.
450451 * @param \DateTime|int $endOrCount Can be either a \DateTime object representing the end of the period to
451452 * receive weather history data for or an integer counting the number of
452- * reports requested.
453+ * reports requested.
453454 * @param string $type The period of the weather history requested. Can be either be either "tick",
454455 * "hour" or "day".
455456 * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
@@ -547,11 +548,11 @@ private function cacheOrFetchResult($type, $query, $units, $lang, $mode, $url)
547548 /**
548549 * Build the url to fetch weather data from.
549550 *
550- * @param $query
551- * @param $units
552- * @param $lang
553- * @param $appid
554- * @param $mode
551+ * @param $query
552+ * @param $units
553+ * @param $lang
554+ * @param $appid
555+ * @param $mode
555556 * @param string $url The url to prepend.
556557 *
557558 * @return bool|string The fetched url, false on failure.
@@ -566,7 +567,7 @@ private function buildUrl($query, $units, $lang, $appid, $mode, $url)
566567 if (!empty ($ appid )) {
567568 $ url .= "&APPID= $ appid " ;
568569 }
569-
570+
570571 return $ url ;
571572 }
572573
@@ -582,7 +583,7 @@ private function buildUrl($query, $units, $lang, $appid, $mode, $url)
582583 */
583584 private function buildQueryUrlParameter ($ query )
584585 {
585- switch ($ query ) {
586+ switch ($ query ) {
586587 case (is_array ($ query ) && isset ($ query ['lat ' ]) && isset ($ query ['lon ' ]) && is_numeric ($ query ['lat ' ]) && is_numeric ($ query ['lon ' ])):
587588 return "lat= {$ query ['lat ' ]}&lon= {$ query ['lon ' ]}" ;
588589 case (is_numeric ($ query )):
0 commit comments