Additional informations on Zend_Currency - Zend_Currency
Additional informations on Zend_Currency
Sometimes it is necessary to get informations which are related to a currency. Zend_Currency provides you with several methods to get this informations. Available methods include the following:
getCurrencyList(): Returns a list of all currencies which are used in the given region as array. Defaults to the objects locale when no region has been given.
getLocale(): Returns the set locale for the actual currency.
getName(): Returns the full name for the actual currency. When there is no full name available for the actual currency, it will return the abbreviation for it.
getRegionList(): Returns a list of all regions where this currency is used as array. Defaults to the objects currency when no currency has been given.
getService(): Returns the set exchange service object for the actual currency.
getShortName(): Returns the abbreviation for the actual currency.
getSymbol(): Returns the currency sign for the currency. When the currency has no symbol, then it will return the abbreviation for it.
getValue(): Returns the set value for the actual currency.
Let's see some code snippets as example:
- $currency = new Zend_Currency();
- // returns 0
- // could return an array with all regions where USD is used
- // returns an array with all regions where EUR is used
- // could return 'US Dollar'
- // returns 'Euro'
As you can see, several methods allow to use additional parameters to override the actual object to get informations for other currencies. Omitting this parameters will return informations from the actual set currency.
Currency Performance Optimization
Zend_Currency's performance can be optimized using Zend_Cache. The static method Zend_Currency::setCache($cache) accepts one option: a Zend_Cache adapter. If the cache adapter is set, the localization data which is used by Zend_Currency will be cached. Additionally there are some static methods for manipulating the cache: getCache(), hasCache(), clearCache() and removeCache().