From 6278dbe42a5b596f211349cdf8cf4a10070d7b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Tue, 17 Dec 2024 11:48:47 +0100 Subject: [PATCH] fix: avoid another null pointer exception --- src/Entity/Destination.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Entity/Destination.php b/src/Entity/Destination.php index 7b5047e..e0cab10 100644 --- a/src/Entity/Destination.php +++ b/src/Entity/Destination.php @@ -175,8 +175,12 @@ class Destination implements TimestampableEntityInterface, SoftDeletableEntityIn return $this; } - public function getPickup(int $id): ?Pickup + public function getPickup(?int $id): ?Pickup { + if (null === $id) { + return null; + } + foreach ($this->getPickups() as $pickup) { if ($id === $pickup['busProId']) { return Pickup::fromArray($pickup);