-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWeatherOverview.php
More file actions
53 lines (39 loc) · 1.17 KB
/
WeatherOverview.php
File metadata and controls
53 lines (39 loc) · 1.17 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
<?php
namespace ProgrammatorDev\OpenWeatherMap\Entity\OneCall;
use ProgrammatorDev\OpenWeatherMap\Entity\Coordinate;
use ProgrammatorDev\OpenWeatherMap\Entity\Timezone;
class WeatherOverview
{
private Coordinate $coordinate;
private Timezone $timezone;
private \DateTimeImmutable $dateTime;
private string $overview;
public function __construct(array $data)
{
$this->coordinate = new Coordinate($data);
$this->timezone = new Timezone([
'timezone_offset' => \DateTimeImmutable::createFromFormat('P', $data['tz'])->getOffset()
]);
$this->dateTime = \DateTimeImmutable::createFromFormat(
'Y-m-d H:i:s P',
sprintf('%s 00:00:00 %s', $data['date'], $data['tz'])
);
$this->overview = $data['weather_overview'];
}
public function getCoordinate(): Coordinate
{
return $this->coordinate;
}
public function getTimezone(): Timezone
{
return $this->timezone;
}
public function getDateTime(): \DateTimeImmutable
{
return $this->dateTime;
}
public function getOverview(): string
{
return $this->overview;
}
}