From b4db04be184b38419149dd72ccdec4e7fd3f75a1 Mon Sep 17 00:00:00 2001 From: dnsimmons Date: Mon, 20 Dec 2021 18:15:38 -0500 Subject: [PATCH] Added config for icons extension format --- src/OpenWeather.php | 16 +++++++++------- src/config/openweather.php | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/OpenWeather.php b/src/OpenWeather.php index e6c8824..53a7254 100644 --- a/src/OpenWeather.php +++ b/src/OpenWeather.php @@ -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; @@ -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'); @@ -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'], @@ -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'], @@ -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'], @@ -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'], @@ -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'], @@ -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'], @@ -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'], diff --git a/src/config/openweather.php b/src/config/openweather.php index 31df256..a513348 100644 --- a/src/config/openweather.php +++ b/src/config/openweather.php @@ -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'),