Files
DatBrowser/app/Browser/Jobs/EldoradoRobuxPriceSentry/EldoradoRobuxPriceNotificationBody.php
Matthias Guillitte 5e6164016c
All checks were successful
Test, build and push image to registry / phpunit-tests (push) Successful in 3m25s
Test, build and push image to registry / build-image (push) Successful in 2m59s
Eldorado : Added the minimum stock threshold
It now look at all of the offers of the first page and select the one matching the criterias
2025-12-20 16:20:07 +01:00

47 lines
1.9 KiB
PHP

<?php
namespace App\Browser\Jobs\EldoradoRobuxPriceSentry;
use App\Notification\NotificationBody;
class EldoradoRobuxPriceNotificationBody extends NotificationBody {
private float $price;
private float $priceThreshold;
private int $stock;
private int|null $stockThreshold;
private string $link;
public function __construct(float $price, float $priceThreshold, int $stock, int|null $stockThreshold, string $link) {
parent::__construct();
$this->price = $price;
$this->priceThreshold = $priceThreshold;
$this->stock = $stock;
$this->stockThreshold = $stockThreshold;
$this->link = $link;
}
/**
* @inheritDoc
*/
public function toMarkdownString(): string {
return "Le prix des Robux sur Eldorado est actuellement de **" . $this->floatFormat($this->price) . " €**/Robux, ce qui est inférieur ou égal au seuil de **" . $this->floatFormat($this->priceThreshold) . " €**.\nLe stock est de **" . $this->intFormat($this->stock) . "**" . ($this->stockThreshold !== null ? " (seuil : **" . $this->intFormat($this->stockThreshold) . "**)" : "") . "\n[Voir l'offre sur Eldorado]( " . $this->link . " )";
}
/**
* @inheritDoc
*/
public function toString(): string {
return "Le prix des Robux sur Eldorado est actuellement de " . $this->floatFormat($this->price) . " €/Robux, ce qui est inférieur ou égal au seuil de " . $this->floatFormat($this->priceThreshold) . " €.\nLe stock est de " . $this->intFormat($this->stock) . ($this->stockThreshold !== null ? " (seuil : " . $this->intFormat($this->stockThreshold) . ")" : "") . "\nVoir l'offre sur Eldorado : " . $this->link;
}
private function floatFormat(float $number): string {
return number_format($number, 5, ",", " ");
}
private function intFormat(int $number): string {
return number_format($number, 0, ",", " ");
}
}