@@ -219,7 +219,7 @@ public function getWeatherForecast($query, $units = 'imperial', $lang = 'en', $a
219219 if ($ days <= 5 ) {
220220 $ answer = $ this ->getRawHourlyForecastData ($ query , $ units , $ lang , $ appid , 'xml ' );
221221 } else if ($ days <= 14 ) {
222- $ answer = $ this ->getRawDailyForecastData ($ query , $ units , $ lang , $ appid , 'xml ' );
222+ $ answer = $ this ->getRawDailyForecastData ($ query , $ units , $ lang , $ appid , 'xml ' , $ days );
223223 } else {
224224 throw new \InvalidArgumentException ('Error: forecasts are only available for the next 14 days. $days must be lower than 15. ' );
225225 }
@@ -237,7 +237,7 @@ public function getWeatherForecast($query, $units = 'imperial', $lang = 'en', $a
237237 }
238238 }
239239
240- return new WeatherForecast ($ xml , $ units );
240+ return new WeatherForecast ($ xml , $ units, $ days );
241241 }
242242
243243 /**
@@ -404,8 +404,10 @@ public function getRawHourlyForecastData($query, $units = 'imperial', $lang = 'e
404404 * @param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
405405 * @param string $lang The language to use for descriptions, default is 'en'. For possible values see below.
406406 * @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).
407+ * @param string $mode The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default)
408+ * @param int $cnt How many days of forecast shall be returned? Maximum (and default): 14
408409 *
410+ * @throws \InvalidArgumentException If $cnt is higher than 14.
409411 * @return string Returns false on failure and the fetched data in the format you specified on success.
410412 *
411413 * Warning If an error occurred, OpenWeatherMap returns data in json format ALWAYS
@@ -436,9 +438,12 @@ public function getRawHourlyForecastData($query, $units = 'imperial', $lang = 'e
436438 *
437439 * @api
438440 */
439- public function getRawDailyForecastData ($ query , $ units = 'imperial ' , $ lang = 'en ' , $ appid = '' , $ mode = 'xml ' )
441+ public function getRawDailyForecastData ($ query , $ units = 'imperial ' , $ lang = 'en ' , $ appid = '' , $ mode = 'xml ' , $ cnt = 14 )
440442 {
441- $ url = $ this ->buildUrl ($ query , $ units , $ lang , $ appid , $ mode , $ this ->weatherDailyForecastUrl );
443+ if ($ cnt > 14 ) {
444+ throw new \InvalidArgumentException ('$cnt must be 14 or below! ' );
445+ }
446+ $ url = $ this ->buildUrl ($ query , $ units , $ lang , $ appid , $ mode , $ this ->weatherDailyForecastUrl ) . "&cnt= $ cnt " ;
442447
443448 return $ this ->cacheOrFetchResult ('dailyForecast ' , $ query , $ units , $ lang , $ mode , $ url );
444449 }
0 commit comments