-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWeatherData.php
More file actions
62 lines (46 loc) · 1.44 KB
/
WeatherData.php
File metadata and controls
62 lines (46 loc) · 1.44 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
<?php
namespace ProgrammatorDev\OpenWeatherMap\Entity\Assistant;
use ProgrammatorDev\OpenWeatherMap\Entity\BaseWeather;
class WeatherData extends BaseWeather
{
private string $locationName;
private float $temperature;
private float $temperatureFeelsLike;
private ?int $visibility;
private \DateTimeImmutable $sunriseAt;
private \DateTimeImmutable $sunsetAt;
public function __construct(string $locationName, array $data)
{
parent::__construct($data);
$this->locationName = $locationName;
$this->temperature = $data['temp'];
$this->temperatureFeelsLike = $data['feels_like'];
$this->visibility = $data['visibility'] ?? null;
$this->sunriseAt = \DateTimeImmutable::createFromFormat('U', $data['sunrise']);
$this->sunsetAt = \DateTimeImmutable::createFromFormat('U', $data['sunset']);
}
public function getLocationName(): string
{
return $this->locationName;
}
public function getTemperature(): float
{
return $this->temperature;
}
public function getTemperatureFeelsLike(): float
{
return $this->temperatureFeelsLike;
}
public function getVisibility(): ?int
{
return $this->visibility;
}
public function getSunriseAt(): \DateTimeImmutable
{
return $this->sunriseAt;
}
public function getSunsetAt(): \DateTimeImmutable
{
return $this->sunsetAt;
}
}