From c85dc5322eb11911860420d59247d605bf86fc8f Mon Sep 17 00:00:00 2001 From: Mohit Aghera Date: Tue, 23 Jan 2024 15:45:14 +0530 Subject: [PATCH 1/6] Add new attributes. --- src/Observation/Pressure.php | 20 +++++++++++ src/Observation/Temperature.php | 40 ++++++++++++++++++++++ src/Observation/Wind.php | 60 +++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+) diff --git a/src/Observation/Pressure.php b/src/Observation/Pressure.php index 2e2026b..bebdfb5 100644 --- a/src/Observation/Pressure.php +++ b/src/Observation/Pressure.php @@ -19,6 +19,26 @@ final class Pressure { */ protected ?int $meanSeaLevel = NULL; + /** + * The pressure, in hectopascals. + */ + protected ?int $pressure = NULL; + + /** + * Gets the pressure in hectopascals. + */ + public function getPressure(): ?int { + return $this->pressure; + } + + /** + * Sets the pressure in hectopascals. + */ + public function setPressure(?int $pressure): Pressure { + $this->pressure = $pressure; + return $this; + } + /** * Gets the PressureQnh. */ diff --git a/src/Observation/Temperature.php b/src/Observation/Temperature.php index 41c63d9..9d847a9 100644 --- a/src/Observation/Temperature.php +++ b/src/Observation/Temperature.php @@ -14,6 +14,16 @@ final class Temperature { */ protected ?float $airTemp = NULL; + /** + * The maximum air temperature, in Celsius. + */ + protected ?float $maximumAirTemp = NULL; + + /** + * The minimum air temperature, in Celsius. + */ + protected ?float $minimumAirTemp = NULL; + /** * The apparent temperature, in Celsius. */ @@ -49,6 +59,36 @@ public function setAirTemp(float $airTemp): Temperature { return $this; } + /** + * Gets the maximum AirTemp. + */ + public function getMaximumAirTemp(): ?float { + return $this->maximumAirTemp; + } + + /** + * Sets the maximum AirTemp. + */ + public function setMaximumAirTemp(float $airTemp): Temperature { + $this->maximumAirTemp = $airTemp; + return $this; + } + + /** + * Gets the minimum AirTemp. + */ + public function getMinimumAirTemp(): ?float { + return $this->minimumAirTemp; + } + + /** + * Sets the minimum AirTemp. + */ + public function setMinimumAirTemp(float $airTemp): Temperature { + $this->minimumAirTemp = $airTemp; + return $this; + } + /** * Gets the ApparentTemp. */ diff --git a/src/Observation/Wind.php b/src/Observation/Wind.php index 003de06..edf2fa6 100644 --- a/src/Observation/Wind.php +++ b/src/Observation/Wind.php @@ -34,6 +34,66 @@ final class Wind { */ protected ?int $gustKnots = NULL; + /** + * The wind gusts, in kilometres per Hour. + */ + protected ?int $maximumGustKmh = NULL; + + /** + * The wind gusts, in knots. + */ + protected ?int $maximumGustSpeed = NULL; + + /** + * Gets the maximum gust speed in kilometers per hour. + */ + public function getMaximumGustKmh(): ?int { + return $this->maximumGustKmh; + } + + /** + * Set the maximum gust speed in kilometers per hour. + */ + public function setMaximumGustKmh(?int $maximumGustKmh): Wind { + $this->maximumGustKmh = $maximumGustKmh; + return $this; + } + + /** + * Gets the maximum gust speed in knots. + */ + public function getMaximumGustSpeed(): ?int { + return $this->maximumGustSpeed; + } + + /** + * Sets the maximum gust speed in knots. + */ + public function setMaximumGustSpeed(?int $maximumGustSpeed): Wind { + $this->maximumGustSpeed = $maximumGustSpeed; + return $this; + } + + /** + * Sets the maximum gust direction. + */ + public function getMaximumGustDirection(): ?int { + return $this->maximumGustDirection; + } + + /** + * Gets the maximum gust direction. + */ + public function setMaximumGustDirection(?int $maximumGustDirection): Wind { + $this->maximumGustDirection = $maximumGustDirection; + return $this; + } + + /** + * The wind gusts, in knots. + */ + protected ?int $maximumGustDirection = NULL; + /** * Gets the Direction. */ From a85f92877521d35dd802b7b9103484e0f1f2dfe3 Mon Sep 17 00:00:00 2001 From: Mohit Aghera Date: Tue, 23 Jan 2024 15:50:15 +0530 Subject: [PATCH 2/6] phpcs fixes. --- src/Observation/Wind.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Observation/Wind.php b/src/Observation/Wind.php index edf2fa6..55b33ad 100644 --- a/src/Observation/Wind.php +++ b/src/Observation/Wind.php @@ -44,6 +44,11 @@ final class Wind { */ protected ?int $maximumGustSpeed = NULL; + /** + * The wind gusts, in knots. + */ + protected ?int $maximumGustDirection = NULL; + /** * Gets the maximum gust speed in kilometers per hour. */ @@ -89,11 +94,6 @@ public function setMaximumGustDirection(?int $maximumGustDirection): Wind { return $this; } - /** - * The wind gusts, in knots. - */ - protected ?int $maximumGustDirection = NULL; - /** * Gets the Direction. */ From 8fd2c9f2461d8de1a5151e691fbb26b308dfc75a Mon Sep 17 00:00:00 2001 From: Mohit Aghera Date: Tue, 23 Jan 2024 15:57:23 +0530 Subject: [PATCH 3/6] Variable type and return type fixes. --- src/Observation/Wind.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Observation/Wind.php b/src/Observation/Wind.php index 55b33ad..58f0089 100644 --- a/src/Observation/Wind.php +++ b/src/Observation/Wind.php @@ -47,7 +47,7 @@ final class Wind { /** * The wind gusts, in knots. */ - protected ?int $maximumGustDirection = NULL; + protected ?string $maximumGustDirection = NULL; /** * Gets the maximum gust speed in kilometers per hour. @@ -82,14 +82,14 @@ public function setMaximumGustSpeed(?int $maximumGustSpeed): Wind { /** * Sets the maximum gust direction. */ - public function getMaximumGustDirection(): ?int { + public function getMaximumGustDirection(): ?string { return $this->maximumGustDirection; } /** * Gets the maximum gust direction. */ - public function setMaximumGustDirection(?int $maximumGustDirection): Wind { + public function setMaximumGustDirection(string $maximumGustDirection): Wind { $this->maximumGustDirection = $maximumGustDirection; return $this; } From d53a46f6b44479659c9aa2cd199b3e9607ceef08 Mon Sep 17 00:00:00 2001 From: Mohit Aghera Date: Wed, 24 Jan 2024 10:41:40 +0530 Subject: [PATCH 4/6] Set wind direction in degree. --- src/Observation/Wind.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Observation/Wind.php b/src/Observation/Wind.php index 58f0089..a3947ac 100644 --- a/src/Observation/Wind.php +++ b/src/Observation/Wind.php @@ -49,6 +49,11 @@ final class Wind { */ protected ?string $maximumGustDirection = NULL; + /** + * The wind direction in degree. + */ + protected ?int $windDirectionDegree = NULL; + /** * Gets the maximum gust speed in kilometers per hour. */ @@ -169,4 +174,19 @@ public function setGustKnots(int $gustKnots): Wind { return $this; } + /** + * Gets the wind direction in degree. + */ + public function getWindDirectionDegree(): ?int { + return $this->windDirectionDegree; + } + + /** + * Sets the wind direction in degree. + */ + public function setWindDirectionDegree(int $gustKnots): Wind { + $this->windDirectionDegree = $gustKnots; + return $this; + } + } From 8b7ed2a78be16c39e0857cd24afb7dcabd445930 Mon Sep 17 00:00:00 2001 From: Mohit Aghera Date: Thu, 1 Feb 2024 18:07:22 +0530 Subject: [PATCH 5/6] Adding additional attributes and array access check. --- .../Serializer/ObservationListNormalizer.php | 4 +- src/Observation/Station.php | 40 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/Observation/Serializer/ObservationListNormalizer.php b/src/Observation/Serializer/ObservationListNormalizer.php index f229aba..86c2683 100644 --- a/src/Observation/Serializer/ObservationListNormalizer.php +++ b/src/Observation/Serializer/ObservationListNormalizer.php @@ -25,7 +25,9 @@ public function denormalize($data, $type, $format = NULL, array $context = []) { } $observationList = new ObservationList(); - $observationList->setRefreshMessage($data['observations']['header'][0]['refresh_message']); + if (\array_key_exists('header', $data['observations'])) { + $observationList->setRefreshMessage($data['observations']['header'][0]['refresh_message']); + } \array_map(function ($observationData) use ($observationList): void { $observationList->addObservation($this->serializer->denormalize($observationData, Observation::class)); diff --git a/src/Observation/Station.php b/src/Observation/Station.php index 31fd11a..e475a51 100644 --- a/src/Observation/Station.php +++ b/src/Observation/Station.php @@ -29,6 +29,16 @@ final class Station { */ protected ?float $longitude = NULL; + /** + * The station ID. + */ + protected ?int $wmoId = NULL; + + /** + * The station ID. + */ + protected string|int|null $bomId = NULL; + /** * Gets the Name. */ @@ -89,4 +99,34 @@ public function setId(int $id): self { return $this; } + /** + * Gets the BOM ID. + */ + public function getBomId(): ?int { + return $this->bomId; + } + + /** + * Sets the BOM ID. + */ + public function setBomId(string|int $id): self { + $this->bomId = $id; + return $this; + } + + /** + * Gets the WMO ID. + */ + public function getWmoId(): ?int { + return $this->wmoId; + } + + /** + * Sets the Wmo ID. + */ + public function setWmoId(int $id): self { + $this->wmoId = $id; + return $this; + } + } From f513579941121cbe9ba0a415afdc6639c61f110f Mon Sep 17 00:00:00 2001 From: Mohit Aghera Date: Wed, 6 Mar 2024 11:39:39 +0530 Subject: [PATCH 6/6] Change the data type of the pressure value. --- src/Observation/Pressure.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Observation/Pressure.php b/src/Observation/Pressure.php index bebdfb5..103a071 100644 --- a/src/Observation/Pressure.php +++ b/src/Observation/Pressure.php @@ -22,19 +22,19 @@ final class Pressure { /** * The pressure, in hectopascals. */ - protected ?int $pressure = NULL; + protected ?float $pressure = NULL; /** * Gets the pressure in hectopascals. */ - public function getPressure(): ?int { + public function getPressure(): ?float { return $this->pressure; } /** * Sets the pressure in hectopascals. */ - public function setPressure(?int $pressure): Pressure { + public function setPressure(?float $pressure): Pressure { $this->pressure = $pressure; return $this; }