Currency.php

Show: PublicProtectedPrivateinherited
Table of Contents
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-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Currency  
Version
$Id$  

\Zend_Currency

Package: Zend_Currency
Class for handling currency notations
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

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

Properties

>VPropertyprotectedarray $_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
Default valuearray('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
 

Methods

methodpublic__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.

Parameters
NameTypeDescription
$optionsstring | array

OPTIONAL Options array or currency short name when string is given

$localestring | \Zend_Locale

OPTIONAL locale name

Throws
ExceptionDescription
\Zend_Currency_ExceptionWhen currency is invalid
methodpublic__toString() : string

Returns the currency name

Returns
TypeDescription
string
methodprotected_checkOptions(array $options = array()) : array

Internal method for checking the options array

Parameters
NameTypeDescription
$optionsarray

Options to check

Returns
TypeDescription
array
Throws
ExceptionDescription
\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
methodprivate_checkParams(string $currency = null, string | \Zend_Locale $locale = null) : string

Internal function for checking static given locale parameter

Parameters
NameTypeDescription
$currencystring

(Optional) Currency name

$localestring | \Zend_Locale

(Optional) Locale to display informations

Returns
TypeDescription
stringThe extracted locale representation as string
Throws
ExceptionDescription
\Zend_Currency_ExceptionWhen locale contains no region
methodprotected_exchangeCurrency(float | integer | \Zend_Currency $value, string | \Zend_Currency $currency) : \unknown

Internal method which calculates the exchanges currency

Parameters
NameTypeDescription
$valuefloat | integer | \Zend_Currency

Compares the currency with this value

$currencystring | \Zend_Currency

The currency to compare this value from

Returns
TypeDescription
\unknown
methodprivate_extractPattern(string $pattern, float | integer $value) : string

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

Parameters
NameTypeDescription
$patternstring
$valuefloat | integer
Returns
TypeDescription
string
methodpublicadd(float | integer | \Zend_Currency $value, string | \Zend_Currency $currency = null) : \Zend_Currency

Adds a currency

Parameters
NameTypeDescription
$valuefloat | integer | \Zend_Currency

Add this value to currency

$currencystring | \Zend_Currency

The currency to add

Returns
TypeDescription
\Zend_Currency
methodpublicclearCache(string $tag = null) : void
static

Clears all set cache data

Parameters
NameTypeDescription
$tagstring

Tag to clear when the default tag name is not used

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

Compares two currencies

Parameters
NameTypeDescription
$valuefloat | integer | \Zend_Currency

Compares the currency with this value

$currencystring | \Zend_Currency

The currency to compare this value from

Returns
TypeDescription
\Zend_Currency
methodpublicdiv(float | integer | \Zend_Currency $value, string | \Zend_Currency $currency = null) : \Zend_Currency

Divides a currency

Parameters
NameTypeDescription
$valuefloat | integer | \Zend_Currency

Divides this value from currency

$currencystring | \Zend_Currency

The currency to divide

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

Returns true when the two currencies are equal

Parameters
NameTypeDescription
$valuefloat | integer | \Zend_Currency

Compares the currency with this value

$currencystring | \Zend_Currency

The currency to compare this value from

Returns
TypeDescription
boolean
methodpublicgetCache() : \Zend_Cache_Core
static

Returns the set cache

Returns
TypeDescription
\Zend_Cache_CoreThe set cache
methodpublicgetCurrencyList(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

Parameters
NameTypeDescription
$regionstring

OPTIONAL Region to return the currencies for

Returns
TypeDescription
arrayList of currencies
methodpublicgetLocale() : string

Returns the actual set locale

Returns
TypeDescription
string
methodpublicgetName(string $currency = null, string | \Zend_Locale $locale = null) : string

Returns the actual or details of other currency names

Parameters
NameTypeDescription
$currencystring

(Optional) Currency's short name

$localestring | \Zend_Locale

(Optional) The locale

Returns
TypeDescription
string
methodpublicgetRegionList(string $currency = null) : array

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

Parameters
NameTypeDescription
$currencystring

OPTIONAL Currency's short name

Returns
TypeDescription
arrayList of regions
Throws
ExceptionDescription
\Zend_Currency_ExceptionWhen no currency was defined
methodpublicgetService() : \Zend_Service

Returns the set service class

Returns
TypeDescription
\Zend_Service
methodpublicgetShortName(string $currency = null, string | \Zend_Locale $locale = null) : string

Returns the actual or details of other currency shortnames

Parameters
NameTypeDescription
$currencystring

OPTIONAL Currency's name

$localestring | \Zend_Locale

OPTIONAL The locale

Returns
TypeDescription
string
methodpublicgetSymbol(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)

Parameters
NameTypeDescription
$currencystring

(Optional) Currency name

$localestring | \Zend_Locale

(Optional) Locale to display informations

Returns
TypeDescription
string
methodpublicgetValue() : float

Returns the value

Returns
TypeDescription
float
methodpublichasCache() : boolean
static

Returns true when a cache is set

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

Returns true when the currency is less than the given value

Parameters
NameTypeDescription
$valuefloat | integer | \Zend_Currency

Compares the currency with this value

$currencystring | \Zend_Currency

The currency to compare this value from

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

Returns true when the currency is more than the given value

Parameters
NameTypeDescription
$valuefloat | integer | \Zend_Currency

Compares the currency with this value

$currencystring | \Zend_Currency

The currency to compare this value from

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

Calculates the modulo from a currency

Parameters
NameTypeDescription
$valuefloat | integer | \Zend_Currency

Calculate modulo from this value

$currencystring | \Zend_Currency

The currency to calculate the modulo

Returns
TypeDescription
\Zend_Currency
methodpublicmul(float | integer | \Zend_Currency $value, string | \Zend_Currency $currency = null) : \Zend_Currency

Multiplies a currency

Parameters
NameTypeDescription
$valuefloat | integer | \Zend_Currency

Multiplies this value from currency

$currencystring | \Zend_Currency

The currency to multiply

Returns
TypeDescription
\Zend_Currency
methodpublicremoveCache() : void
static

Removes any set cache

methodpublicsetCache(\Zend_Cache_Core $cache) : void
static

Sets a cache for Zend_Currency

Parameters
NameTypeDescription
$cache\Zend_Cache_Core

Cache to set

methodpublicsetFormat(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

Parameters
NameTypeDescription
$optionsarray

(Optional) Options to set

Returns
TypeDescription
\Zend_Currency
methodpublicsetLocale(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

Parameters
NameTypeDescription
$localestring | \Zend_Locale

(Optional) Locale for parsing input

Returns
TypeDescription
\Zend_CurrencyProvides fluent interface
Throws
ExceptionDescription
\Zend_Currency_ExceptionWhen the given locale does not exist
methodpublicsetService(string | \Zend_Currency_CurrencyInterface $service) : \Zend_Currency

Sets a new exchange service

Parameters
NameTypeDescription
$servicestring | \Zend_Currency_CurrencyInterface

Service class

Returns
TypeDescription
\Zend_Currency
methodpublicsetValue(float | integer | \Zend_Currency $value, string | \Zend_Currency $currency = null) : \Zend_Currency

Adds a currency

Parameters
NameTypeDescription
$valuefloat | integer | \Zend_Currency

Add this value to currency

$currencystring | \Zend_Currency

The currency to add

Returns
TypeDescription
\Zend_Currency
methodpublicsub(float | integer | \Zend_Currency $value, string | \Zend_Currency $currency = null) : \Zend_Currency

Substracts a currency

Parameters
NameTypeDescription
$valuefloat | integer | \Zend_Currency

Substracts this value from currency

$currencystring | \Zend_Currency

The currency to substract

Returns
TypeDescription
\Zend_Currency
methodpublictoCurrency(integer | float $value = null, array $options = array()) : string

Returns a localized currency string

Parameters
NameTypeDescription
$valueinteger | float

OPTIONAL Currency value

$optionsarray

OPTIONAL options to set temporary

Returns
TypeDescription
string
Throws
ExceptionDescription
\Zend_Currency_ExceptionWhen the value is not a number
methodpublictoString() : string

Returns the actual currency name

Returns
TypeDescription
string
Documentation was generated by phpDocumentor 2.2.0 .