<?php
namespace App\Services\Currency;
use Exception;
class CurrencyManager
{
public function getCurrentRate()
{
try {
$currencyData = json_decode($this->getJsonFileContent(), true);
} catch (Exception $e) {
echo $e->getMessage();
}
return $currencyData;
}
/**
* @return string
*/
private function getJsonFileContent()
{
if (!$file = @file_get_contents(base_path('currency.json'))) {
throw new Exception('File currency.json underfined or has errors. Please check the file.');
}
return $file;
}
}