WebTorque\CurrencyConverter\CurrencyConverter
Base class for Currency Converter
Currencies should be stored in associative array with the currency code as the key
e.g.
array(
'NZD' => '1.5',
'USD' => '1.2'
);
Synopsis
class CurrencyConverter
{
- // members
- private static $converter = EuropaXMLCurrencyConverter::class;
- private $cache = NULL;
- protected array $currencies = ;
- // methods
- public static CurrencyConverter getConverter()
- public void getCurrencies()
- public void setCurrencies()
- public CacheInterface getCache()
- public mixed loadFromCache()
- public mixed saveToCache()
- private void getCacheKey()
- public DBDecimal convert()
- public float getExchangeRate()
- public void loadCurrencies()
- public float rateForCurrency()
- public mixed retrieveCurrencies()
- public string getBaseCurrency()
Hierarchy
Uses
- SilverStripe\Core\Config\Configurable
- SilverStripe\Core\Injector\Injectable
Members
private
- $cache
- $converter
protected
- $currencies
Methods
private
public
- convert() — Convert a value from one currency to another
- getBaseCurrency() — The base currency for the returned currencies
- getCache()
- getConverter()
- getCurrencies()
- getExchangeRate() — Get the exchange rate for converting from one currency to another
- loadCurrencies() — Load currencies, checks cache first, otherwise calls retreiveCurrencies
- loadFromCache() — Load currencies from Cache
- rateForCurrency() — Returns the rate for the passed currency
- retrieveCurrencies() — Load currencies from source
- saveToCache() — Save currencies to cache
- setCurrencies()