-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDayData.php
More file actions
96 lines (75 loc) · 2.25 KB
/
DayData.php
File metadata and controls
96 lines (75 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
namespace ProgrammatorDev\OpenWeatherMap\Entity\OneCall;
class DayData extends BaseWeather
{
private Temperature $temperature;
private Temperature $temperatureFeelsLike;
private int $precipitationProbability;
private string $summary;
private MoonPhase $moonPhase;
private \DateTimeImmutable $moonriseAt;
private \DateTimeImmutable $moonsetAt;
private \DateTimeImmutable $sunriseAt;
private \DateTimeImmutable $sunsetAt;
public function __construct(array $data)
{
parent::__construct($data);
$this->temperature = new Temperature($data['temp']);
$this->temperatureFeelsLike = new Temperature($data['feels_like']);
$this->precipitationProbability = round($data['pop'] * 100);
$this->summary = $data['summary'];
$this->moonPhase = new MoonPhase($data);
$this->moonriseAt = \DateTimeImmutable::createFromFormat('U', $data['moonrise']);
$this->moonsetAt = \DateTimeImmutable::createFromFormat('U', $data['moonset']);
$this->sunriseAt = \DateTimeImmutable::createFromFormat('U', $data['sunrise']);
$this->sunsetAt = \DateTimeImmutable::createFromFormat('U', $data['sunset']);
}
public function getTemperature(): Temperature
{
return $this->temperature;
}
public function getTemperatureFeelsLike(): Temperature
{
return $this->temperatureFeelsLike;
}
public function getPrecipitationProbability(): int
{
return $this->precipitationProbability;
}
public function getSummary(): string
{
return $this->summary;
}
public function getMoonPhase(): MoonPhase
{
return $this->moonPhase;
}
/**
* Moonrise date in UTC
*/
public function getMoonriseAt(): \DateTimeImmutable
{
return $this->moonriseAt;
}
/**
* Moonset date in UTC
*/
public function getMoonsetAt(): \DateTimeImmutable
{
return $this->moonsetAt;
}
/**
* Sunrise date in UTC
*/
public function getSunriseAt(): \DateTimeImmutable
{
return $this->sunriseAt;
}
/**
* Sunset date in UTC
*/
public function getSunsetAt(): \DateTimeImmutable
{
return $this->sunsetAt;
}
}