Skip to content

Commit f59cb94

Browse files
authored
Merge branch 'master' into master
2 parents 98e99f8 + dadc126 commit f59cb94

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

Cmfcmf/OpenWeatherMap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class OpenWeatherMap
4040
*
4141
* @var string $copyright
4242
*/
43-
const COPYRIGHT = "Weather data from <a href=\"http://www.openweathermap.org\">OpenWeatherMap.org</a>";
43+
const COPYRIGHT = "Weather data from <a href=\"http://openweathermap.org\">OpenWeatherMap.org</a>";
4444

4545
/**
4646
* @var string The basic api url to fetch weather data from.
@@ -199,7 +199,7 @@ public function getWeather($query, $units = 'imperial', $lang = 'en', $appid = '
199199
* @throws OpenWeatherMap\Exception If OpenWeatherMap returns an error.
200200
* @throws \InvalidArgumentException If an argument error occurs.
201201
*
202-
* @return Array Array of CurrentWeather objects.
202+
* @return CurrentWeatherGroup
203203
*
204204
* @api
205205
*/

Cmfcmf/OpenWeatherMap/CurrentWeather.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717

1818
namespace Cmfcmf\OpenWeatherMap;
1919

20-
use Cmfcmf\OpenWeatherMap;
2120
use Cmfcmf\OpenWeatherMap\Util\City;
2221
use Cmfcmf\OpenWeatherMap\Util\Sun;
2322
use Cmfcmf\OpenWeatherMap\Util\Temperature;
2423
use Cmfcmf\OpenWeatherMap\Util\Unit;
25-
use Cmfcmf\OpenWeatherMap\Util\Weather as WeatherObj;
24+
use Cmfcmf\OpenWeatherMap\Util\Weather;
2625
use Cmfcmf\OpenWeatherMap\Util\Wind;
2726

2827
/**
@@ -112,7 +111,7 @@ public function __construct($data, $units)
112111
$this->clouds = new Unit($data->clouds['value'], null, $data->clouds['name']);
113112
$this->precipitation = new Unit($data->precipitation['value'], $data->precipitation['unit'], $data->precipitation['mode']);
114113
$this->sun = new Sun(new \DateTime($data->city->sun['rise'], $utctz), new \DateTime($data->city->sun['set'], $utctz));
115-
$this->weather = new WeatherObj($data->weather['number'], $data->weather['value'], $data->weather['icon']);
114+
$this->weather = new Weather($data->weather['number'], $data->weather['value'], $data->weather['icon']);
116115
$this->lastUpdate = new \DateTime($data->lastupdate['value'], $utctz);
117116
} else {
118117
$this->city = new City($data->id, $data->name, $data->coord->lon, $data->coord->lat, $data->sys->country);
@@ -130,7 +129,7 @@ public function __construct($data, $units)
130129
$this->precipitation = new Unit($rainValue, $rainUnit);
131130

132131
$this->sun = new Sun(\DateTime::createFromFormat('U', $data->sys->sunrise, $utctz), \DateTime::createFromFormat('U', $data->sys->sunset, $utctz));
133-
$this->weather = new WeatherObj($data->weather[0]->id, $data->weather[0]->description, $data->weather[0]->icon);
132+
$this->weather = new Weather($data->weather[0]->id, $data->weather[0]->description, $data->weather[0]->icon);
134133
$this->lastUpdate = \DateTime::createFromFormat('U', $data->dt, $utctz);
135134
}
136135
}

Cmfcmf/OpenWeatherMap/Forecast.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Cmfcmf\OpenWeatherMap\Util\Temperature;
2121
use Cmfcmf\OpenWeatherMap\Util\Time;
2222
use Cmfcmf\OpenWeatherMap\Util\Unit;
23-
use Cmfcmf\OpenWeatherMap\Util\Weather as WeatherObj;
23+
use Cmfcmf\OpenWeatherMap\Util\Weather;
2424
use Cmfcmf\OpenWeatherMap\Util\Wind;
2525

2626
/**
@@ -65,7 +65,7 @@ public function __construct(\SimpleXMLElement $xml, $units)
6565
$this->wind = new Wind(new Unit($xml->windSpeed['mps'], $windSpeedUnit, $xml->windSpeed['name']), new Unit($xml->windDirection['deg'], $xml->windDirection['code'], $xml->windDirection['name']));
6666
$this->clouds = new Unit($xml->clouds['all'], $xml->clouds['unit'], $xml->clouds['value']);
6767
$this->precipitation = new Unit($xml->precipitation['value'], null, $xml->precipitation['type']);
68-
$this->weather = new WeatherObj($xml->symbol['number'], $xml->symbol['name'], $xml->symbol['var']);
68+
$this->weather = new Weather($xml->symbol['number'], $xml->symbol['name'], $xml->symbol['var']);
6969
$this->lastUpdate = new \DateTime($xml->lastupdate['value']);
7070

7171
if (isset($xml['from'])) {

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 sprintf($this->iconUrl, $this->icon);
80+
return sprintf(self::$iconUrl, $this->icon);
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)