From 1d24750f43f1d87f8908f33c20adca4e313975dd Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 29 Jul 2024 19:59:46 +0200 Subject: [PATCH] Fix phpstan checks --- .../src/EventDispatcher/PublishingUpdatesGenerator.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/module/Core/src/EventDispatcher/PublishingUpdatesGenerator.php b/module/Core/src/EventDispatcher/PublishingUpdatesGenerator.php index 211768b3..b762af7e 100644 --- a/module/Core/src/EventDispatcher/PublishingUpdatesGenerator.php +++ b/module/Core/src/EventDispatcher/PublishingUpdatesGenerator.php @@ -18,7 +18,7 @@ final readonly class PublishingUpdatesGenerator implements PublishingUpdatesGene public function newVisitUpdate(Visit $visit): Update { return Update::forTopicAndPayload(Topic::NEW_VISIT->value, [ - 'shortUrl' => $this->shortUrlTransformer->transform($visit->shortUrl), + 'shortUrl' => $this->transformShortUrl($visit->shortUrl), 'visit' => $visit->jsonSerialize(), ]); } @@ -36,7 +36,7 @@ final readonly class PublishingUpdatesGenerator implements PublishingUpdatesGene $topic = Topic::newShortUrlVisit($shortUrl?->getShortCode()); return Update::forTopicAndPayload($topic, [ - 'shortUrl' => $this->shortUrlTransformer->transform($shortUrl), + 'shortUrl' => $this->transformShortUrl($shortUrl), 'visit' => $visit->jsonSerialize(), ]); } @@ -47,4 +47,9 @@ final readonly class PublishingUpdatesGenerator implements PublishingUpdatesGene 'shortUrl' => $this->shortUrlTransformer->transform($shortUrl), ]); } + + private function transformShortUrl(?ShortUrl $shortUrl): array + { + return $shortUrl === null ? [] : $this->shortUrlTransformer->transform($shortUrl); + } }