Changeset View
Changeset View
Standalone View
Standalone View
src/app/Backends/OpenExchangeRates.php
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | public static function retrieveRates($baseCurrency) | ||||
if (count($rates) > 1) { | if (count($rates) > 1) { | ||||
$rates[$baseCurrency] = 1; | $rates[$baseCurrency] = 1; | ||||
return $rates; | return $rates; | ||||
} | } | ||||
throw new \Exception("Failed to retrieve exchange rates"); | throw new \Exception("Failed to retrieve exchange rates"); | ||||
} | } | ||||
/** | |||||
* Validates that openexchange is available as configured. | |||||
* | |||||
* @throws \Exception | |||||
*/ | |||||
public static function healthcheck(): void | |||||
{ | |||||
$apiKey = \config('services.openexchangerates.api_key'); | |||||
machniak: Redundant spaces here and below. | |||||
if (!empty($apiKey)) { | |||||
$query = http_build_query(['app_id' => $apiKey]); | |||||
Done Inline ActionsSpacing. machniak: Spacing. | |||||
$url = 'https://openexchangerates.org/api/usage.json' . $query; | |||||
$html = file_get_contents($url, false); | |||||
if ($html && ($result = json_decode($html, true)) && !empty($result['status'])) { | |||||
print($result); | |||||
} | |||||
throw new \Exception("Failed to retrieve exchange rates status"); | |||||
} | |||||
} | |||||
} | } |
Redundant spaces here and below.