1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Rawaby88\OpenWeatherMap\Services\Support; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class Temperature. |
7
|
|
|
*/ |
8
|
|
|
class Temperature |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @var int the temperature. |
12
|
|
|
*/ |
13
|
|
|
public $temp; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var int the temperature feel likes. |
17
|
|
|
*/ |
18
|
|
|
public $feelsLike; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var int the maximum temperature. |
22
|
|
|
*/ |
23
|
|
|
public $tempMax; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var int the minimum temperature. |
27
|
|
|
*/ |
28
|
|
|
public $tempMin; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var int Weather pressure. |
32
|
|
|
*/ |
33
|
|
|
public $pressure; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var int Weather humidity. |
37
|
|
|
*/ |
38
|
|
|
public $humidity; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Temperature constructor. |
42
|
|
|
* @param float $temp the temperature |
43
|
|
|
* @param float $feelsLike the temperature feel likes. |
44
|
|
|
* @param float $tempMin the maximum temperature. |
45
|
|
|
* @param float $tempMax the minimum temperature. |
46
|
|
|
* @param int $pressure Weather pressure. |
47
|
|
|
* @param int $humidity Weather humidity. |
48
|
|
|
*/ |
49
|
|
|
public function __construct(float $temp, float $feelsLike, float $tempMin, float $tempMax, int $pressure, int $humidity) |
50
|
|
|
{ |
51
|
|
|
$this->temp = round($temp); |
52
|
|
|
$this->feelsLike = round($feelsLike); |
53
|
|
|
$this->tempMax = round($tempMax); |
54
|
|
|
$this->tempMin = round($tempMin); |
55
|
|
|
$this->pressure = $pressure; |
56
|
|
|
$this->humidity = $humidity; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Encoding to json. |
61
|
|
|
* @return false|string |
62
|
|
|
*/ |
63
|
|
|
public function toJson() |
64
|
|
|
{ |
65
|
|
|
return json_encode( |
66
|
|
|
[ |
67
|
|
|
'temp' => $this->temp, |
68
|
|
|
'feelsLike' => $this->feelsLike, |
69
|
|
|
'tempMax' => $this->tempMax, |
70
|
|
|
'tempMin' => $this->tempMin, |
71
|
|
|
'pressure' => $this->pressure, |
72
|
|
|
'humidity' => $this->humidity, |
73
|
|
|
] |
74
|
|
|
); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|