]> git.mxchange.org Git - friendica-addons.git/blob - curweather/vendor/cmfcmf/openweathermap-php-api/Cmfcmf/OpenWeatherMap/Util/Weather.php
added composer.json and needed libs
[friendica-addons.git] / curweather / vendor / cmfcmf / openweathermap-php-api / Cmfcmf / OpenWeatherMap / Util / Weather.php
1 <?php
2 /**
3  * OpenWeatherMap-PHP-API — A php api to parse weather data from http://www.OpenWeatherMap.org .
4  *
5  * @license MIT
6  *
7  * Please see the LICENSE file distributed with this source code for further
8  * information regarding copyright and licensing.
9  *
10  * Please visit the following links to read about the usage policies and the license of
11  * OpenWeatherMap before using this class:
12  *
13  * @see http://www.OpenWeatherMap.org
14  * @see http://www.OpenWeatherMap.org/terms
15  * @see http://openweathermap.org/appid
16  */
17
18 namespace Cmfcmf\OpenWeatherMap\Util;
19
20 /**
21  * The weather class representing a weather object.
22  */
23 class Weather
24 {
25     /**
26      * @var int The weather id.
27      */
28     public $id;
29
30     /**
31      * @var string The weather description.
32      */
33     public $description;
34
35     /**
36      * @var string the icon name.
37      */
38     public $icon;
39
40     /**
41      * @var string The url for icons.
42      *
43      * @see self::getIconUrl() to see how it is used.
44      */
45     private $iconUrl = "http://openweathermap.org/img/w/%s.png";
46
47     /**
48      * Create a new weather object.
49      *
50      * @param int    $id          The icon id.
51      * @param string $description The weather description.
52      * @param string $icon        The icon name.
53      *
54      * @internal
55      */
56     public function __construct($id, $description, $icon)
57     {
58         $this->id = (int)$id;
59         $this->description = (string)$description;
60         $this->icon = (string)$icon;
61     }
62
63     /**
64      * Get the weather description.
65      *
66      * @return string
67      */
68     public function __toString()
69     {
70         return $this->description;
71     }
72
73     /**
74      * Get the icon url.
75      *
76      * @return string The icon url.
77      */
78     public function getIconUrl()
79     {
80         return str_replace("%s", $this->icon, $this->iconUrl);
81     }
82 }