mrcage / chf-exchange-rates
Retrieves Swiss Franc exchange rates for foreign currencies based on data from the website of the Swiss Federal Customs Administration.
Installs: 1 049
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
Requires
- php: ^8.1.
- illuminate/support: ^9|^10
- nesbot/carbon: ^2.0
Requires (Dev)
- phpunit/phpunit: ^9.0|^10.0
README
Retrieves Swiss Franc exchange rates for foreign currencies based on data from the website of the Swiss Federal Customs Administration.
The library uses internal caching of requested data (cache time is one week).
Usage
Include class
use MrCage\EzvExchangeRates\EzvExchangeRates;
Get exchange rate for current day
$rate = EzvExchangeRates::getExchangeRate('EUR');
Get exchange rate for a day in the past
The date must be specified as Carbon date object.
$rate = EzvExchangeRates::getExchangeRate('USD', Carbon::yesterday());
Get all available currencies
$currencies = EzvExchangeRates::listCurrencies();
This will return a list of currency codes as an array, the key being the (uppercase) currency code, and the value being the base value used for the exchange rate.