Files
ladill-servers/app/Services/ExchangeRateService.php
isaaccladandCursor b6c8ac343f Extract Ladill Servers as standalone app at servers.ladill.com.
VPS and dedicated server ordering, managed panels, SSO, billing, and launcher integration — forked from hosting infrastructure with server-focused routes and dashboard.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-06 19:18:30 +00:00

53 lines
1.2 KiB
PHP

<?php
namespace App\Services;
use App\Services\Currency\CurrencyConverterService;
class ExchangeRateService
{
public function __construct(
private CurrencyConverterService $currency,
) {}
public function getUsdToGhs(): float
{
return $this->currency->getUsdToGhsRate();
}
public function getEurToGhs(): float
{
return $this->currency->getEurToGhsRate();
}
public function fetchLiveRate(): float
{
return $this->currency->refreshRate();
}
public function refreshRate(): float
{
return $this->currency->refreshRate();
}
public function getCachedRate(): ?float
{
$info = $this->currency->getRateInfo();
return ($info['cached'] ?? false)
? (float) ($info['rate'] ?? 0)
: null;
}
public function getRateInfo(): array
{
$info = $this->currency->getRateInfo();
return [
'rate' => (float) ($info['rate'] ?? 0),
'is_cached' => (bool) ($info['cached'] ?? false),
'fallback_rate' => (float) ($info['fallback'] ?? config('hosting.pricing.fallback_usd_to_ghs_rate', 15.50)),
];
}
}