Currency.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Currency
- Version
- $Id: Currency.php 24855 2012-06-01 00:12:25Z adamlundrigan $
\Zend_Currency
Class for handling currency notations
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants
Properties


array $_options = array('position' => self::STANDARD, 'script' => null, 'format' => null, 'display' => self::NO_SYMBOL, 'precision' => 2, 'name' => null, 'currency' => null, 'symbol' => null, 'locale' => null, 'value' => 0, 'service' => null, 'tag' => 'Zend_Locale')
Options array
The following options are available 'position' => Position for the currency sign 'script' => Script for the output 'format' => Locale for numeric output 'display' => Currency detail to show 'precision' => Precision for the currency 'name' => Name for this currency 'currency' => 3 lettered international abbreviation 'symbol' => Currency symbol 'locale' => Locale for this currency 'value' => Money value 'service' => Exchange service to use
array('position' => self::STANDARD, 'script' => null, 'format' => null, 'display' => self::NO_SYMBOL, 'precision' => 2, 'name' => null, 'currency' => null, 'symbol' => null, 'locale' => null, 'value' => 0, 'service' => null, 'tag' => 'Zend_Locale')
Details- Type
- array
- See
- \global\Zend_Locale
Methods


__construct(string | array $options = null, string | \Zend_Locale $locale = null) : void
Creates a currency instance.
Every supressed parameter is used from the actual or the given locale.
Name | Type | Description |
---|---|---|
$options | string | array | OPTIONAL Options array or currency short name when string is given |
$locale | string | \Zend_Locale | OPTIONAL locale name |
Exception | Description |
---|---|
\Zend_Currency_Exception | When currency is invalid |


_checkOptions(array $options = array()) : array
Internal method for checking the options array
Name | Type | Description |
---|---|---|
$options | array | Options to check |
Type | Description |
---|---|
array |
Exception | Description |
---|---|
\Zend_Currency_Exception | On unknown position |
\Zend_Currency_Exception | On unknown locale |
\Zend_Currency_Exception | On unknown display |
\Zend_Currency_Exception | On precision not between -1 and 30 |
\Zend_Currency_Exception | On problem with script conversion |
\Zend_Currency_Exception | On unknown options |


_checkParams(string $currency = null, string | \Zend_Locale $locale = null) : string
Internal function for checking static given locale parameter
Name | Type | Description |
---|---|---|
$currency | string | (Optional) Currency name |
$locale | string | \Zend_Locale | (Optional) Locale to display informations |
Type | Description |
---|---|
string | The extracted locale representation as string |
Exception | Description |
---|---|
\Zend_Currency_Exception | When locale contains no region |


_exchangeCurrency(float | integer | \Zend_Currency $value, string | \Zend_Currency $currency) : \unknown
Internal method which calculates the exchanges currency
Name | Type | Description |
---|---|---|
$value | float | integer | \Zend_Currency | Compares the currency with this value |
$currency | string | \Zend_Currency | The currency to compare this value from |
Type | Description |
---|---|
\unknown |


_extractPattern(string $pattern, float | integer $value) : string
Internal method to extract the currency pattern when a choice is given based on the given value
Name | Type | Description |
---|---|---|
$pattern | string | |
$value | float | integer |
Type | Description |
---|---|
string |


add(float | integer | \Zend_Currency $value, string | \Zend_Currency $currency = null) : \Zend_Currency
Adds a currency
Name | Type | Description |
---|---|---|
$value | float | integer | \Zend_Currency | Add this value to currency |
$currency | string | \Zend_Currency | The currency to add |
Type | Description |
---|---|
\Zend_Currency |


clearCache(string $tag = null) : void
Clears all set cache data
Name | Type | Description |
---|---|---|
$tag | string | Tag to clear when the default tag name is not used |


compare(float | integer | \Zend_Currency $value, string | \Zend_Currency $currency = null) : \Zend_Currency
Compares two currencies
Name | Type | Description |
---|---|---|
$value | float | integer | \Zend_Currency | Compares the currency with this value |
$currency | string | \Zend_Currency | The currency to compare this value from |
Type | Description |
---|---|
\Zend_Currency |


div(float | integer | \Zend_Currency $value, string | \Zend_Currency $currency = null) : \Zend_Currency
Divides a currency
Name | Type | Description |
---|---|---|
$value | float | integer | \Zend_Currency | Divides this value from currency |
$currency | string | \Zend_Currency | The currency to divide |
Type | Description |
---|---|
\Zend_Currency |


equals(float | integer | \Zend_Currency $value, string | \Zend_Currency $currency = null) : boolean
Returns true when the two currencies are equal
Name | Type | Description |
---|---|---|
$value | float | integer | \Zend_Currency | Compares the currency with this value |
$currency | string | \Zend_Currency | The currency to compare this value from |
Type | Description |
---|---|
boolean |


getCache() : \Zend_Cache_Core
Returns the set cache
Type | Description |
---|---|
\Zend_Cache_Core | The set cache |


getCurrencyList(string $region = null) : array
Returns a list of currencies which are used in this region a region name should be 2 charachters only (f.e.
EG, DE, US) If no region is given, the actual region is used
Name | Type | Description |
---|---|---|
$region | string | OPTIONAL Region to return the currencies for |
Type | Description |
---|---|
array | List of currencies |


getName(string $currency = null, string | \Zend_Locale $locale = null) : string
Returns the actual or details of other currency names
Name | Type | Description |
---|---|---|
$currency | string | (Optional) Currency's short name |
$locale | string | \Zend_Locale | (Optional) The locale |
Type | Description |
---|---|
string |


getRegionList(string $currency = null) : array
Returns a list of regions where this currency is or was known
Name | Type | Description |
---|---|---|
$currency | string | OPTIONAL Currency's short name |
Type | Description |
---|---|
array | List of regions |
Exception | Description |
---|---|
\Zend_Currency_Exception | When no currency was defined |


getShortName(string $currency = null, string | \Zend_Locale $locale = null) : string
Returns the actual or details of other currency shortnames
Name | Type | Description |
---|---|---|
$currency | string | OPTIONAL Currency's name |
$locale | string | \Zend_Locale | OPTIONAL The locale |
Type | Description |
---|---|
string |


getSymbol(string $currency = null, string | \Zend_Locale $locale = null) : string
Returns the actual or details of other currency symbols, when no symbol is available it returns the currency shortname (f.e.
FIM for Finnian Mark)
Name | Type | Description |
---|---|---|
$currency | string | (Optional) Currency name |
$locale | string | \Zend_Locale | (Optional) Locale to display informations |
Type | Description |
---|---|
string |


isLess(float | integer | \Zend_Currency $value, string | \Zend_Currency $currency = null) : boolean
Returns true when the currency is less than the given value
Name | Type | Description |
---|---|---|
$value | float | integer | \Zend_Currency | Compares the currency with this value |
$currency | string | \Zend_Currency | The currency to compare this value from |
Type | Description |
---|---|
boolean |


isMore(float | integer | \Zend_Currency $value, string | \Zend_Currency $currency = null) : boolean
Returns true when the currency is more than the given value
Name | Type | Description |
---|---|---|
$value | float | integer | \Zend_Currency | Compares the currency with this value |
$currency | string | \Zend_Currency | The currency to compare this value from |
Type | Description |
---|---|
boolean |


mod(float | integer | \Zend_Currency $value, string | \Zend_Currency $currency = null) : \Zend_Currency
Calculates the modulo from a currency
Name | Type | Description |
---|---|---|
$value | float | integer | \Zend_Currency | Calculate modulo from this value |
$currency | string | \Zend_Currency | The currency to calculate the modulo |
Type | Description |
---|---|
\Zend_Currency |


mul(float | integer | \Zend_Currency $value, string | \Zend_Currency $currency = null) : \Zend_Currency
Multiplies a currency
Name | Type | Description |
---|---|---|
$value | float | integer | \Zend_Currency | Multiplies this value from currency |
$currency | string | \Zend_Currency | The currency to multiply |
Type | Description |
---|---|
\Zend_Currency |


setCache(\Zend_Cache_Core $cache) : void
Sets a cache for Zend_Currency
Name | Type | Description |
---|---|---|
$cache | \Zend_Cache_Core | Cache to set |


setFormat(array $options = array()) : \Zend_Currency
Sets the formating options of the localized currency string If no parameter is passed, the standard setting of the actual set locale will be used
Name | Type | Description |
---|---|---|
$options | array | (Optional) Options to set |
Type | Description |
---|---|
\Zend_Currency |


setLocale(string | \Zend_Locale $locale = null) : \Zend_Currency
Sets a new locale for data retreivement Example: 'de_XX' will be set to 'de' because 'de_XX' does not exist 'xx_YY' will be set to 'root' because 'xx' does not exist
Name | Type | Description |
---|---|---|
$locale | string | \Zend_Locale | (Optional) Locale for parsing input |
Type | Description |
---|---|
\Zend_Currency | Provides fluent interface |
Exception | Description |
---|---|
\Zend_Currency_Exception | When the given locale does not exist |


setService(string | \Zend_Currency_CurrencyInterface $service) : \Zend_Currency
Sets a new exchange service
Name | Type | Description |
---|---|---|
$service | string | \Zend_Currency_CurrencyInterface | Service class |
Type | Description |
---|---|
\Zend_Currency |


setValue(float | integer | \Zend_Currency $value, string | \Zend_Currency $currency = null) : \Zend_Currency
Adds a currency
Name | Type | Description |
---|---|---|
$value | float | integer | \Zend_Currency | Add this value to currency |
$currency | string | \Zend_Currency | The currency to add |
Type | Description |
---|---|
\Zend_Currency |


sub(float | integer | \Zend_Currency $value, string | \Zend_Currency $currency = null) : \Zend_Currency
Substracts a currency
Name | Type | Description |
---|---|---|
$value | float | integer | \Zend_Currency | Substracts this value from currency |
$currency | string | \Zend_Currency | The currency to substract |
Type | Description |
---|---|
\Zend_Currency |


toCurrency(integer | float $value = null, array $options = array()) : string
Returns a localized currency string
Name | Type | Description |
---|---|---|
$value | integer | float | OPTIONAL Currency value |
$options | array | OPTIONAL options to set temporary |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Currency_Exception | When the value is not a number |