Class for handling currency notations

category Zend
package Zend_Currency
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License

 Methods

Creates a currency instance. Every supressed parameter is used from the actual or the given locale.

__construct(string|array $options = null, string|\Zend_Locale $locale = null

Parameters

$options

stringarray

OPTIONAL Options array or currency short name when string is given

$locale

string\Zend_Locale

OPTIONAL locale name

Exceptions

\Zend_Currency_Exception When currency is invalid

Returns the currency name

__toString() : string

Returns

string

Adds a currency

add(float|integer|\Zend_Currency $value, string|\Zend_Currency $currency = null) : \Zend_Currency

Parameters

$value

floatinteger\Zend_Currency

Add this value to currency

$currency

string\Zend_Currency

The currency to add

Returns

\Zend_Currency

Clears all set cache data

clearCache(string $tag = null) : void
Static

Parameters

$tag

string

Tag to clear when the default tag name is not used

Compares two currencies

compare(float|integer|\Zend_Currency $value, string|\Zend_Currency $currency = null) : \Zend_Currency

Parameters

$value

floatinteger\Zend_Currency

Compares the currency with this value

$currency

string\Zend_Currency

The currency to compare this value from

Returns

\Zend_Currency

Divides a currency

div(float|integer|\Zend_Currency $value, string|\Zend_Currency $currency = null) : \Zend_Currency

Parameters

$value

floatinteger\Zend_Currency

Divides this value from currency

$currency

string\Zend_Currency

The currency to divide

Returns

\Zend_Currency

Returns true when the two currencies are equal

equals(float|integer|\Zend_Currency $value, string|\Zend_Currency $currency = null) : boolean

Parameters

$value

floatinteger\Zend_Currency

Compares the currency with this value

$currency

string\Zend_Currency

The currency to compare this value from

Returns

boolean

Returns the set cache

getCache() : \Zend_Cache_Core
Static

Returns

\Zend_Cache_CoreThe set cache

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

getCurrencyList(string $region = null) : array

Parameters

$region

string

OPTIONAL Region to return the currencies for

Returns

arrayList of currencies

Returns the actual set locale

getLocale() : string

Returns

string

Returns the actual or details of other currency names

getName(string $currency = null, string|\Zend_Locale $locale = null) : string

Parameters

$currency

string

(Optional) Currency's short name

$locale

string\Zend_Locale

(Optional) The locale

Returns

string

Returns a list of regions where this currency is or was known

getRegionList(string $currency = null) : array

Parameters

$currency

string

OPTIONAL Currency's short name

Exceptions

\Zend_Currency_Exception When no currency was defined

Returns

arrayList of regions

Returns the set service class

getService() : \Zend_Service

Returns

\Zend_Service

Returns the actual or details of other currency shortnames

getShortName(string $currency = null, string|\Zend_Locale $locale = null) : string

Parameters

$currency

string

OPTIONAL Currency's name

$locale

string\Zend_Locale

OPTIONAL The locale

Returns

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)

getSymbol(string $currency = null, string|\Zend_Locale $locale = null) : string

Parameters

$currency

string

(Optional) Currency name

$locale

string\Zend_Locale

(Optional) Locale to display informations

Returns

string

Returns the value

getValue() : float

Returns

float

Returns true when a cache is set

hasCache() : boolean
Static

Returns

boolean

Returns true when the currency is less than the given value

isLess(float|integer|\Zend_Currency $value, string|\Zend_Currency $currency = null) : boolean

Parameters

$value

floatinteger\Zend_Currency

Compares the currency with this value

$currency

string\Zend_Currency

The currency to compare this value from

Returns

boolean

Returns true when the currency is more than the given value

isMore(float|integer|\Zend_Currency $value, string|\Zend_Currency $currency = null) : boolean

Parameters

$value

floatinteger\Zend_Currency

Compares the currency with this value

$currency

string\Zend_Currency

The currency to compare this value from

Returns

boolean

Calculates the modulo from a currency

mod(float|integer|\Zend_Currency $value, string|\Zend_Currency $currency = null) : \Zend_Currency

Parameters

$value

floatinteger\Zend_Currency

Calculate modulo from this value

$currency

string\Zend_Currency

The currency to calculate the modulo

Returns

\Zend_Currency

Multiplies a currency

mul(float|integer|\Zend_Currency $value, string|\Zend_Currency $currency = null) : \Zend_Currency

Parameters

$value

floatinteger\Zend_Currency

Multiplies this value from currency

$currency

string\Zend_Currency

The currency to multiply

Returns

\Zend_Currency

Removes any set cache

removeCache() : void
Static

Sets a cache for Zend_Currency

setCache(\Zend_Cache_Core $cache) : void
Static

Parameters

$cache

\Zend_Cache_Core

Cache to set

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

setFormat(array $options = array()) : \Zend_Currency

Parameters

$options

array

(Optional) Options to set

Returns

\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

setLocale(string|\Zend_Locale $locale = null) : \Zend_Currency

Parameters

$locale

string\Zend_Locale

(Optional) Locale for parsing input

Exceptions

\Zend_Currency_Exception When the given locale does not exist

Returns

\Zend_CurrencyProvides fluent interface

Sets a new exchange service

setService(string|\Zend_Currency_CurrencyInterface $service) : \Zend_Currency

Parameters

$service

string\Zend_Currency_CurrencyInterface

Service class

Returns

\Zend_Currency

Adds a currency

setValue(float|integer|\Zend_Currency $value, string|\Zend_Currency $currency = null) : \Zend_Currency

Parameters

$value

floatinteger\Zend_Currency

Add this value to currency

$currency

string\Zend_Currency

The currency to add

Returns

\Zend_Currency

Substracts a currency

sub(float|integer|\Zend_Currency $value, string|\Zend_Currency $currency = null) : \Zend_Currency

Parameters

$value

floatinteger\Zend_Currency

Substracts this value from currency

$currency

string\Zend_Currency

The currency to substract

Returns

\Zend_Currency

Returns a localized currency string

toCurrency(integer|float $value = null, array $options = array()) : string

Parameters

$value

integerfloat

OPTIONAL Currency value

$options

array

OPTIONAL options to set temporary

Exceptions

\Zend_Currency_Exception When the value is not a number

Returns

string

Returns the actual currency name

toString() : string

Returns

string

Internal method for checking the options array

_checkOptions(array $options = array()) : array

Parameters

$options

array

Options to check

Exceptions

\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

Returns

array

Internal method which calculates the exchanges currency

_exchangeCurrency(float|integer|\Zend_Currency $value, string|\Zend_Currency $currency) : \unknown

Parameters

$value

floatinteger\Zend_Currency

Compares the currency with this value

$currency

string\Zend_Currency

The currency to compare this value from

Returns

\unknown

Internal function for checking static given locale parameter

_checkParams(string $currency = null, string|\Zend_Locale $locale = null) : string

Parameters

$currency

string

(Optional) Currency name

$locale

string\Zend_Locale

(Optional) Locale to display informations

Exceptions

\Zend_Currency_Exception When locale contains no region

Returns

stringThe extracted locale representation as string

Internal method to extract the currency pattern when a choice is given based on the given value

_extractPattern(string $pattern, float|integer $value) : string

Parameters

$pattern

string

$value

floatinteger

Returns

string

 Properties

 

Options array

$_options : array

Default

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')

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

see

 Constants

 

LEFT

LEFT = 32 
 

NO_SYMBOL

NO_SYMBOL = 1 
 

RIGHT

RIGHT = 16 
 

STANDARD

STANDARD = 8 
 

USE_NAME

USE_NAME = 4 
 

USE_SHORTNAME

USE_SHORTNAME = 3 
 

USE_SYMBOL

USE_SYMBOL = 2