1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
*/ |
5
|
|
|
declare(strict_types=1); |
6
|
|
|
namespace Forecast; |
7
|
|
|
use Forecast\Model\Humidity; |
8
|
|
|
use Forecast\Model\Precipitation; |
9
|
|
|
use Forecast\Model\Temperature; |
10
|
|
|
use Forecast\Model\Wind; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Класс предатсавляет информацию о текущей погоде |
14
|
|
|
* |
15
|
|
|
* PHP version 5.5 |
16
|
|
|
* |
17
|
|
|
* @package Forecast |
18
|
|
|
* @author Sergey V.Kuzin <[email protected]> |
19
|
|
|
* @license http://opensource.org/licenses/MIT The MIT License (MIT) |
20
|
|
|
* |
21
|
|
|
*/ |
22
|
|
|
class Current implements ForecastItemInterface |
23
|
|
|
{ |
24
|
|
|
/** @var string Информация солнце */ |
25
|
|
|
protected $summary = null; |
26
|
|
|
|
27
|
|
|
/** @var Temperature Информация о темперетуре */ |
28
|
|
|
protected $temperature = null; |
29
|
|
|
|
30
|
|
|
/** @var Wind Информация о ветре */ |
31
|
|
|
protected $wind = null; |
32
|
|
|
|
33
|
|
|
/** @var Humidity Информация о влажности */ |
34
|
|
|
protected $humidity = null; |
35
|
|
|
|
36
|
|
|
/** @var Precipitation вероятность осадков */ |
37
|
|
|
protected $precipitation = null; |
38
|
|
|
/** |
39
|
|
|
* Получение температуры |
40
|
|
|
* |
41
|
|
|
* @api |
42
|
|
|
* |
43
|
|
|
* @return Temperature |
44
|
|
|
*/ |
45
|
|
|
public function getTemperature(): Temperature |
46
|
|
|
{ |
47
|
|
|
return $this->temperature; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Ветер |
52
|
|
|
* |
53
|
|
|
* @api |
54
|
|
|
* @return Wind |
55
|
|
|
*/ |
56
|
|
|
public function getWind(): Wind |
57
|
|
|
{ |
58
|
|
|
return $this->wind; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Солнце |
63
|
|
|
* |
64
|
|
|
* @api |
65
|
|
|
* @return string |
66
|
|
|
*/ |
67
|
|
|
public function getSummary() |
68
|
|
|
{ |
69
|
|
|
return $this->summary; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Возвращает объект хронящий информацию о влажновсти |
74
|
|
|
* |
75
|
|
|
* @api |
76
|
|
|
* @return Humidity |
77
|
|
|
*/ |
78
|
|
|
public function getHumidity() |
79
|
|
|
{ |
80
|
|
|
return $this->humidity; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return Precipitation |
85
|
|
|
*/ |
86
|
|
|
public function getPrecipitation() |
87
|
|
|
{ |
88
|
|
|
return $this->precipitation; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @param array $data Устанвыочные данные о погоде |
93
|
|
|
* @return Current |
94
|
|
|
*/ |
95
|
|
|
public function setData(array $data): ForecastItemInterface |
96
|
|
|
{ |
97
|
|
|
$this->summary = $data['summary']; |
98
|
|
|
$this->temperature = (new Temperature())->setData($data['temperature']); |
99
|
|
|
$this->wind = (new Wind())->setData($data['wind']); |
100
|
|
|
$this->precipitation = (new Precipitation())->setData($data['precipitation']); |
101
|
|
|
$this->humidity = (new Humidity())->setData($data['humidity']); |
102
|
|
|
|
103
|
|
|
return $this; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Возвращает строку |
108
|
|
|
* |
109
|
|
|
* @api |
110
|
|
|
* |
111
|
|
|
* @return string |
112
|
|
|
*/ |
113
|
|
|
public function __toString() |
114
|
|
|
{ |
115
|
|
|
return (string)$this->getSummary(); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @return string |
120
|
|
|
*/ |
121
|
|
|
public function getIcon(): string |
122
|
|
|
{ |
123
|
|
|
// TODO: Implement getIcon() method. |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|