Zend Framework  1.12
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Zend_Currency Class Reference

Public Member Functions

 __construct ($options=null, $locale=null)
 Creates a currency instance.
 
 toCurrency ($value=null, array $options=array())
 Returns a localized currency string.
 
 setFormat (array $options=array())
 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.
 
 getSymbol ($currency=null, $locale=null)
 Returns the actual or details of other currency symbols, when no symbol is available it returns the currency shortname (f.e.
 
 getShortName ($currency=null, $locale=null)
 Returns the actual or details of other currency shortnames.
 
 getName ($currency=null, $locale=null)
 Returns the actual or details of other currency names.
 
 getRegionList ($currency=null)
 Returns a list of regions where this currency is or was known.
 
 getCurrencyList ($region=null)
 Returns a list of currencies which are used in this region a region name should be 2 charachters only (f.e.
 
 toString ()
 Returns the actual currency name.
 
 __toString ()
 Returns the currency name.
 
 setLocale ($locale=null)
 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.
 
 getLocale ()
 Returns the actual set locale.
 
 getValue ()
 Returns the value.
 
 setValue ($value, $currency=null)
 Adds a currency.
 
 add ($value, $currency=null)
 Adds a currency.
 
 sub ($value, $currency=null)
 Substracts a currency.
 
 div ($value, $currency=null)
 Divides a currency.
 
 mul ($value, $currency=null)
 Multiplies a currency.
 
 mod ($value, $currency=null)
 Calculates the modulo from a currency.
 
 compare ($value, $currency=null)
 Compares two currencies.
 
 equals ($value, $currency=null)
 Returns true when the two currencies are equal.
 
 isMore ($value, $currency=null)
 Returns true when the currency is more than the given value.
 
 isLess ($value, $currency=null)
 Returns true when the currency is less than the given value.
 
 getService ()
 Returns the set service class.
 
 setService ($service)
 Sets a new exchange service.
 

Static Public Member Functions

static getCache ()
 Returns the set cache.
 
static setCache (Zend_Cache_Core $cache)
 Sets a cache for Zend_Currency.
 
static hasCache ()
 Returns true when a cache is set.
 
static removeCache ()
 Removes any set cache.
 
static clearCache ($tag=null)
 Clears all set cache data.
 

Public Attributes

const NO_SYMBOL = 1
 
const USE_SYMBOL = 2
 
const USE_SHORTNAME = 3
 
const USE_NAME = 4
 
const STANDARD = 8
 
const RIGHT = 16
 
const LEFT = 32
 

Protected Member Functions

 _exchangeCurrency ($value, $currency)
 Internal method which calculates the exchanges currency.
 
 _checkOptions (array $options=array())
 Internal method for checking the options array.
 

Protected Attributes

 $_options
 

Constructor & Destructor Documentation

__construct (   $options = null,
  $locale = null 
)

Creates a currency instance.

Every supressed parameter is used from the actual or the given locale.

Parameters
string | array$optionsOPTIONAL Options array or currency short name when string is given
string | Zend_Locale$localeOPTIONAL locale name
Exceptions
Zend_Currency_ExceptionWhen currency is invalid

Member Function Documentation

__toString ( )

Returns the currency name.

Returns
string
_checkOptions ( array  $options = array())
protected

Internal method for checking the options array.

Parameters
array$optionsOptions to check
Exceptions
Zend_Currency_ExceptionOn unknown position
Zend_Currency_ExceptionOn unknown locale
Zend_Currency_ExceptionOn unknown display
Zend_Currency_ExceptionOn precision not between -1 and 30
Zend_Currency_ExceptionOn problem with script conversion
Zend_Currency_ExceptionOn unknown options
Returns
array
_exchangeCurrency (   $value,
  $currency 
)
protected

Internal method which calculates the exchanges currency.

Parameters
float | integer | Zend_Currency$valueCompares the currency with this value
string | Zend_Currency$currencyThe currency to compare this value from
Returns
unknown
add (   $value,
  $currency = null 
)

Adds a currency.

Parameters
float | integer | Zend_Currency$valueAdd this value to currency
string | Zend_Currency$currencyThe currency to add
Returns
Zend_Currency
static clearCache (   $tag = null)
static

Clears all set cache data.

Parameters
string$tagTag to clear when the default tag name is not used
Returns
void
compare (   $value,
  $currency = null 
)

Compares two currencies.

Parameters
float | integer | Zend_Currency$valueCompares the currency with this value
string | Zend_Currency$currencyThe currency to compare this value from
Returns
Zend_Currency
div (   $value,
  $currency = null 
)

Divides a currency.

Parameters
float | integer | Zend_Currency$valueDivides this value from currency
string | Zend_Currency$currencyThe currency to divide
Returns
Zend_Currency
equals (   $value,
  $currency = null 
)

Returns true when the two currencies are equal.

Parameters
float | integer | Zend_Currency$valueCompares the currency with this value
string | Zend_Currency$currencyThe currency to compare this value from
Returns
boolean
static getCache ( )
static

Returns the set cache.

Returns
Zend_Cache_Core The set cache
getCurrencyList (   $region = null)

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

Parameters
string$regionOPTIONAL Region to return the currencies for
Returns
array List of currencies
getLocale ( )

Returns the actual set locale.

Returns
string
getName (   $currency = null,
  $locale = null 
)

Returns the actual or details of other currency names.

Parameters
string$currency(Optional) Currency's short name
string | Zend_Locale$locale(Optional) The locale
Returns
string
getRegionList (   $currency = null)

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

Parameters
string$currencyOPTIONAL Currency's short name
Exceptions
Zend_Currency_ExceptionWhen no currency was defined
Returns
array List of regions
getService ( )

Returns the set service class.

Returns
Zend_Service
getShortName (   $currency = null,
  $locale = null 
)

Returns the actual or details of other currency shortnames.

Parameters
string$currencyOPTIONAL Currency's name
string | Zend_Locale$localeOPTIONAL The locale
Returns
string
getSymbol (   $currency = null,
  $locale = null 
)

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)

Parameters
string$currency(Optional) Currency name
string | Zend_Locale$locale(Optional) Locale to display informations
Returns
string
getValue ( )

Returns the value.

Returns
float
static hasCache ( )
static

Returns true when a cache is set.

Returns
boolean
isLess (   $value,
  $currency = null 
)

Returns true when the currency is less than the given value.

Parameters
float | integer | Zend_Currency$valueCompares the currency with this value
string | Zend_Currency$currencyThe currency to compare this value from
Returns
boolean
isMore (   $value,
  $currency = null 
)

Returns true when the currency is more than the given value.

Parameters
float | integer | Zend_Currency$valueCompares the currency with this value
string | Zend_Currency$currencyThe currency to compare this value from
Returns
boolean
mod (   $value,
  $currency = null 
)

Calculates the modulo from a currency.

Parameters
float | integer | Zend_Currency$valueCalculate modulo from this value
string | Zend_Currency$currencyThe currency to calculate the modulo
Returns
Zend_Currency
mul (   $value,
  $currency = null 
)

Multiplies a currency.

Parameters
float | integer | Zend_Currency$valueMultiplies this value from currency
string | Zend_Currency$currencyThe currency to multiply
Returns
Zend_Currency
static removeCache ( )
static

Removes any set cache.

Returns
void
static setCache ( Zend_Cache_Core  $cache)
static

Sets a cache for Zend_Currency.

Parameters
Zend_Cache_Core$cacheCache to set
Returns
void
setFormat ( array  $options = array())

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.

Parameters
array$options(Optional) Options to set
Returns
Zend_Currency
setLocale (   $locale = null)

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.

Parameters
string | Zend_Locale$locale(Optional) Locale for parsing input
Exceptions
Zend_Currency_ExceptionWhen the given locale does not exist
Returns
Zend_Currency Provides fluent interface
setService (   $service)

Sets a new exchange service.

Parameters
string | Zend_Currency_CurrencyInterface$serviceService class
Returns
Zend_Currency
setValue (   $value,
  $currency = null 
)

Adds a currency.

Parameters
float | integer | Zend_Currency$valueAdd this value to currency
string | Zend_Currency$currencyThe currency to add
Returns
Zend_Currency
sub (   $value,
  $currency = null 
)

Substracts a currency.

Parameters
float | integer | Zend_Currency$valueSubstracts this value from currency
string | Zend_Currency$currencyThe currency to substract
Returns
Zend_Currency
toCurrency (   $value = null,
array  $options = array() 
)

Returns a localized currency string.

Parameters
integer | float$valueOPTIONAL Currency value
array$optionsOPTIONAL options to set temporary
Exceptions
Zend_Currency_ExceptionWhen the value is not a number
Returns
string
toString ( )

Returns the actual currency name.

Returns
string

Member Data Documentation

$_options
protected
Initial value:
= 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'
)
const LEFT = 32
const NO_SYMBOL = 1
const RIGHT = 16
const STANDARD = 8
const USE_NAME = 4
const USE_SHORTNAME = 3
const USE_SYMBOL = 2