Skip to content

Commit dadc126

Browse files
committed
Remove http: from icon url, allow globally overwriting icon url template, closes #92.
1 parent 870e328 commit dadc126

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Cmfcmf/OpenWeatherMap/Util/Weather.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Weather
4242
*
4343
* @see self::getIconUrl() to see how it is used.
4444
*/
45-
private $iconUrl = "http://openweathermap.org/img/w/%s.png";
45+
private static $iconUrl = "//openweathermap.org/img/w/%s.png";
4646

4747
/**
4848
* Create a new weather object.
@@ -77,6 +77,17 @@ public function __toString()
7777
*/
7878
public function getIconUrl()
7979
{
80-
return str_replace("%s", $this->icon, $this->iconUrl);
80+
return str_replace("%s", $this->icon, self::$iconUrl);
81+
}
82+
83+
/**
84+
* Change the url template for icon urls. Please note: This will change the url template for
85+
* all instances of this library.
86+
*
87+
* @param string $iconUrl The url template to build the icon urls.
88+
*/
89+
public static function setIconUrlTemplate($iconUrl)
90+
{
91+
self::$iconUrl = $iconUrl;
8192
}
8293
}

0 commit comments

Comments
 (0)