From bcef42b58e3ce892d50160c706bca03c13f7d2a4 Mon Sep 17 00:00:00 2001 From: Matthias Guillitte Date: Thu, 6 Nov 2025 17:16:36 +0100 Subject: [PATCH] Fix Eldorado text to float conversion and PSR-4 --- .../EldoradoRobuxPriceNotificationBody.php | 2 +- .../EldoradoRobuxPriceSentryJob.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Browser/Jobs/EldoradoRobuxPriceSentry/EldoradoRobuxPriceNotificationBody.php b/app/Browser/Jobs/EldoradoRobuxPriceSentry/EldoradoRobuxPriceNotificationBody.php index 97741b2..aa7c9a9 100644 --- a/app/Browser/Jobs/EldoradoRobuxPriceSentry/EldoradoRobuxPriceNotificationBody.php +++ b/app/Browser/Jobs/EldoradoRobuxPriceSentry/EldoradoRobuxPriceNotificationBody.php @@ -1,6 +1,6 @@ driver->findElement(WebDriverBy::xpath('(//eld-offer-price)[2]/strong')); $lowestPriceText = $lowestPriceElement->getText(); // Ex: " 0,00478 € " - $lowestPrice = (float)str_replace(["€", ","], ["", "."], trim($lowestPriceText)); + $lowestPrice = $this->textToFloat($lowestPriceText); $lowestPrice = $lowestPrice / 1000; // Price per Robux // TODO : Look at the entire text to try to understand if it is per 1k or per single Robux - $threshold = floatval(str_replace(",", ".", $this->jobInfos->get("eldorado_robux_price_threshold"))); + $threshold = $this->textToFloat($this->jobInfos->get("eldorado_robux_price_threshold")); dump($threshold); Log::info("EldoradoRobuxPriceSentryJob: lowest price = $lowestPrice €, threshold = $threshold €"); @@ -131,4 +131,9 @@ class EldoradoRobuxPriceSentryJob extends BrowserJob implements ShouldBeUniqueUn Log::info("EldoradoRobuxPriceSentryJob: no alert sent"); } } + + private function textToFloat(string $text): float + { + return floatval(str_replace(["€", ","], ["", "."], trim($text))); + } }