|
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; |
|
19
|
|
|
|
|
20
|
|
|
use Cmfcmf\OpenWeatherMap\Util\Temperature; |
|
21
|
|
|
use Cmfcmf\OpenWeatherMap\Util\Unit; |
|
22
|
|
|
use Cmfcmf\OpenWeatherMap\Util\Weather; |
|
23
|
|
|
use Cmfcmf\OpenWeatherMap\Util\Wind; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Class WeatherHistory. |
|
27
|
|
|
*/ |
|
28
|
|
|
class History |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* The city object. |
|
32
|
|
|
* |
|
33
|
|
|
* @var Util\City |
|
34
|
|
|
*/ |
|
35
|
|
|
public $city; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* The temperature object. |
|
39
|
|
|
* |
|
40
|
|
|
* @var Util\Temperature |
|
41
|
|
|
*/ |
|
42
|
|
|
public $temperature; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var Util\Unit |
|
46
|
|
|
*/ |
|
47
|
|
|
public $humidity; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var Util\Unit |
|
51
|
|
|
*/ |
|
52
|
|
|
public $pressure; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var Util\Wind |
|
56
|
|
|
*/ |
|
57
|
|
|
public $wind; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @var Util\Unit |
|
61
|
|
|
*/ |
|
62
|
|
|
public $clouds; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @var Util\Unit |
|
66
|
|
|
*/ |
|
67
|
|
|
public $precipitation; |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @var Util\Weather |
|
71
|
|
|
*/ |
|
72
|
|
|
public $weather; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @var \DateTime The time of the history. |
|
76
|
|
|
*/ |
|
77
|
|
|
public $time; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @param $city |
|
81
|
|
|
* @param $weather |
|
82
|
|
|
* @param $temperature |
|
83
|
|
|
* @param $pressure |
|
84
|
|
|
* @param $humidity |
|
85
|
|
|
* @param $clouds |
|
86
|
|
|
* @param $rain |
|
87
|
|
|
* @param $wind |
|
88
|
|
|
* @param $time |
|
89
|
|
|
* |
|
90
|
|
|
* @internal |
|
91
|
|
|
*/ |
|
92
|
6 |
|
public function __construct($city, $weather, $temperature, $pressure, $humidity, $clouds, $rain, $wind, $time) |
|
93
|
|
|
{ |
|
94
|
6 |
|
$this->city = $city; |
|
95
|
6 |
|
$this->weather = new Weather($weather['id'], $weather['description'], $weather['icon']); |
|
96
|
6 |
|
$this->temperature = new Temperature(new Unit($temperature['now'] - 273.15, "\xB0C"), new Unit($temperature['min'] - 273.15, "\xB0C"), new Unit($temperature['max'] - 273.15, "\xB0C")); |
|
97
|
6 |
|
$this->pressure = new Unit($pressure, 'kPa'); |
|
98
|
6 |
|
$this->humidity = new Unit($humidity, '%'); |
|
99
|
6 |
|
$this->clouds = new Unit($clouds, '%'); |
|
100
|
6 |
|
$this->precipitation = new Unit($rain['val'], $rain['unit']); |
|
101
|
6 |
|
$this->wind = new Wind(new Unit($wind['speed']), new Unit($wind['deg'])); |
|
102
|
6 |
|
$this->time = $time; |
|
103
|
6 |
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|