Skip to content

Commit 2ea57ea

Browse files
author
Andreas Aagaard
committed
# Added readme
1 parent 56d9403 commit 2ea57ea

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

config/weather.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22

33
return [
4-
'api_key' => env('OWM_API_KEY')
4+
'api_key' => env('OWM_API_KEY')
55
];

readme.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ php artisan vendor:publish --provider="QuickOrder\Weather\WeatherServiceProvider
1717
use \QuickOrder\Weather\Weather;
1818

1919
$weather = Weather::getWeather(
20-
'zip:5000,DK'
20+
'Odense'
21+
);
22+
23+
$weatherForecast = Weather::getWeatherForecast(
24+
'Odense'
2125
);
2226

2327
```

src/Weather.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,20 @@
88

99
class Weather {
1010

11+
/**
12+
* @var OpenWeatherMap|mixed
13+
*/
14+
1115
protected static $owm;
1216

1317
public function __construct() {
1418
self::$owm = self::getOwm();
1519
}
1620

21+
/**
22+
* @return OpenWeatherMap|mixed
23+
*/
24+
1725
private static function getOwm() {
1826
return self::$owm ? self::$owm : new OpenWeatherMap(
1927
config('weather.api_key'),
@@ -22,7 +30,31 @@ private static function getOwm() {
2230
);
2331
}
2432

33+
/**
34+
* @param $query
35+
* @param string $units
36+
* @param string $lang
37+
* @param string $appid
38+
* @return OpenWeatherMap\CurrentWeather
39+
* @throws OpenWeatherMap\Exception
40+
*/
41+
2542
public static function getWeather($query, $units = 'imperial', $lang = 'en', $appid = '') {
2643
return self::getOwm()->getWeather($query, $units, $lang, $appid);
2744
}
45+
46+
/**
47+
* @param $query
48+
* @param string $units
49+
* @param string $lang
50+
* @param string $appid
51+
* @param int $days
52+
* @return OpenWeatherMap\WeatherForecast
53+
* @throws OpenWeatherMap\Exception
54+
*/
55+
56+
public static function getWeatherForecast($query, $units = 'imperial', $lang = 'en', $appid = '', $days = 1) {
57+
return self::getOwm()->getWeatherForecast($query, $units, $lang, $appid, $days);
58+
59+
}
2860
}

0 commit comments

Comments
 (0)