Skip to content

Commit

Permalink
Added config for icons extension format
Browse files Browse the repository at this point in the history
  • Loading branch information
dnsimmons committed Dec 20, 2021
1 parent d67ac36 commit b4db04b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/OpenWeather.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class OpenWeather
private $api_endpoint_onecall = NULL;
private $api_endpoint_history = NULL;
private $api_endpoint_icons = NULL;
private $api_endpoint_icons_ext = NULL;
private $api_lang = NULL;
private $format_date = NULL;
private $format_time = NULL;
Expand All @@ -42,6 +43,7 @@ public function __construct()
$this->api_endpoint_onecall = Config::get('openweather.api_endpoint_onecall');
$this->api_endpoint_history = Config::get('openweather.api_endpoint_history');
$this->api_endpoint_icons = Config::get('openweather.api_endpoint_icons');
$this->api_endpoint_icons_ext = Config::get('openweather.api_endpoint_icons_ext');
$this->api_lang = Config::get('openweather.api_lang');
$this->format_date = Config::get('openweather.format_date');
$this->format_time = Config::get('openweather.format_time');
Expand Down Expand Up @@ -140,7 +142,7 @@ private function parseCurrentResponse(string $response)
'id' => $struct['weather'][0]['id'],
'name' => $struct['weather'][0]['main'],
'desc' => $struct['weather'][0]['description'],
'icon' => $this->api_endpoint_icons . $struct['weather'][0]['icon'] . '.png',
'icon' => $this->api_endpoint_icons . $struct['weather'][0]['icon'] . '.'.$this->api_endpoint_icons_ext,
],
'wind' => [
'speed' => $struct['wind']['speed'],
Expand Down Expand Up @@ -189,7 +191,7 @@ private function parseForecastResponse(string $response)
'id' => $item['weather'][0]['id'],
'name' => $item['weather'][0]['main'],
'desc' => $item['weather'][0]['description'],
'icon' => $this->api_endpoint_icons . $item['weather'][0]['icon'] . '.png',
'icon' => $this->api_endpoint_icons . $item['weather'][0]['icon'] . '.'.$this->api_endpoint_icons_ext,
],
'wind' => [
'speed' => $item['wind']['speed'],
Expand Down Expand Up @@ -255,7 +257,7 @@ private function parseOnecallResponse(string $response)
'id' => $struct['current']['weather'][0]['id'],
'name' => $struct['current']['weather'][0]['main'],
'desc' => $struct['current']['weather'][0]['description'],
'icon' => $this->api_endpoint_icons . $struct['current']['weather'][0]['icon'] . '.png',
'icon' => $this->api_endpoint_icons . $struct['current']['weather'][0]['icon'] . '.'.$this->api_endpoint_icons_ext,
];
$current['wind'] = [
'speed' => $struct['current']['wind_speed'],
Expand Down Expand Up @@ -292,7 +294,7 @@ private function parseOnecallResponse(string $response)
'id' => $item['weather'][0]['id'],
'name' => $item['weather'][0]['main'],
'desc' => $item['weather'][0]['description'],
'icon' => $this->api_endpoint_icons . $item['weather'][0]['icon'] . '.png',
'icon' => $this->api_endpoint_icons . $item['weather'][0]['icon'] . '.'.$this->api_endpoint_icons_ext,
],
'wind' => [
'speed' => $item['wind_speed'],
Expand Down Expand Up @@ -327,7 +329,7 @@ private function parseOnecallResponse(string $response)
'id' => $item['weather'][0]['id'],
'name' => $item['weather'][0]['main'],
'desc' => $item['weather'][0]['description'],
'icon' => $this->api_endpoint_icons . $item['weather'][0]['icon'] . '.png',
'icon' => $this->api_endpoint_icons . $item['weather'][0]['icon'] . '.'.$this->api_endpoint_icons_ext,
],
'wind' => [
'speed' => $item['wind_speed'],
Expand Down Expand Up @@ -396,7 +398,7 @@ private function parseHistoricalResponse(string $response)
'id' => $struct['current']['weather'][0]['id'],
'name' => $struct['current']['weather'][0]['main'],
'desc' => $struct['current']['weather'][0]['description'],
'icon' => $this->api_endpoint_icons . $struct['current']['weather'][0]['icon'] . '.png',
'icon' => $this->api_endpoint_icons . $struct['current']['weather'][0]['icon'] . '.'.$this->api_endpoint_icons_ext,
];
$current['wind'] = [
'speed' => $struct['current']['wind_speed'],
Expand Down Expand Up @@ -428,7 +430,7 @@ private function parseHistoricalResponse(string $response)
'id' => $item['weather'][0]['id'],
'name' => $item['weather'][0]['main'],
'desc' => $item['weather'][0]['description'],
'icon' => $this->api_endpoint_icons . $item['weather'][0]['icon'] . '.png',
'icon' => $this->api_endpoint_icons . $item['weather'][0]['icon'] . '.'.$this->api_endpoint_icons_ext,
],
'wind' => [
'speed' => $item['wind_speed'],
Expand Down
1 change: 1 addition & 0 deletions src/config/openweather.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'api_endpoint_onecall' => 'https://api.openweathermap.org/data/2.5/onecall?',
'api_endpoint_history' => 'https://api.openweathermap.org/data/2.5/onecall/timemachine?',
'api_endpoint_icons' => 'https://openweathermap.org/img/w/',
'api_endpoint_icons_ext' => 'png',
'api_lang' => env('OPENWEATHER_API_LANG', 'en'),
'format_date' => env('OPENWEATHER_API_DATE_FORMAT', 'm/d/Y'),
'format_time' => env('OPENWEATHER_API_TIME_FORMAT', 'h:i A'),
Expand Down

0 comments on commit b4db04b

Please sign in to comment.