API Documentation

Zend/Currency.php

Show: inherited
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 license@zend.com 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 24594 2012-01-05 21:27:01Z matthew $  

\Zend_Currency

Package: 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

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

Properties

Propertyprotectedarray  $_options= 'array( 'position' => self::STANDARD'

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::STANDARDDetails
Type
array
See
\Zend_Locale  

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
Name Type Description
$options string|array

OPTIONAL Options array or currency short name when string is given

$locale string|\Zend_Locale

OPTIONAL locale name

Throws
Exception Description
\Zend_Currency_Exception When currency is invalid
methodpublic__toString( ) : string

Returns the currency name

Returns
Type Description
string
methodprotected_checkOptions( array $options = array() ) : array

Internal method for checking the options array

Parameters
Name Type Description
$options array

Options to check

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

Internal function for checking static given locale parameter

Parameters
Name Type Description
$currency string

(Optional) Currency name

$locale string|\Zend_Locale

(Optional) Locale to display informations

Returns
Type Description
string The extracted locale representation as string
Throws
Exception Description
\Zend_Currency_Exception When locale contains no region
methodprotected_exchangeCurrency( float|integer|\Zend_Currency $value, string|\Zend_Currency $currency ) : \unknown

Internal method which calculates the exchanges currency

Parameters
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

Returns
Type Description
\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
Name Type Description
$pattern string
$value float|integer
Returns
Type Description
string
methodpublicadd( float|integer|\Zend_Currency $value, string|\Zend_Currency $currency = null ) : \Zend_Currency

Adds a currency

Parameters
Name Type Description
$value float|integer|\Zend_Currency

Add this value to currency

$currency string|\Zend_Currency

The currency to add

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

Clears all set cache data

Parameters
Name Type Description
$tag string

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

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

Divides a currency

Parameters
Name Type Description
$value float|integer|\Zend_Currency

Divides this value from currency

$currency string|\Zend_Currency

The currency to divide

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

Returns true when the two currencies are equal

Parameters
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

Returns
Type Description
boolean
methodpublicgetCache( ) : \Zend_Cache_Core
static

Returns the set cache

Returns
Type Description
\Zend_Cache_Core The 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
Name Type Description
$region string

OPTIONAL Region to return the currencies for

Returns
Type Description
array List of currencies
methodpublicgetLocale( ) : string

Returns the actual set locale

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

Returns the actual or details of other currency names

Parameters
Name Type Description
$currency string

(Optional) Currency's short name

$locale string|\Zend_Locale

(Optional) The locale

Returns
Type Description
string
methodpublicgetRegionList( string $currency = null ) : array

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

Parameters
Name Type Description
$currency string

OPTIONAL Currency's short name

Returns
Type Description
array List of regions
Throws
Exception Description
\Zend_Currency_Exception When no currency was defined
methodpublicgetService( ) : \Zend_Service

Returns the set service class

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

Returns the actual or details of other currency shortnames

Parameters
Name Type Description
$currency string

OPTIONAL Currency's name

$locale string|\Zend_Locale

OPTIONAL The locale

Returns
Type Description
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
Name Type Description
$currency string

(Optional) Currency name

$locale string|\Zend_Locale

(Optional) Locale to display informations

Returns
Type Description
string
methodpublicgetValue( ) : float

Returns the value

Returns
Type Description
float
methodpublichasCache( ) : boolean
static

Returns true when a cache is set

Returns
Type Description
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
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

Returns
Type Description
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
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

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

Calculates the modulo from a currency

Parameters
Name Type Description
$value float|integer|\Zend_Currency

Calculate modulo from this value

$currency string|\Zend_Currency

The currency to calculate the modulo

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

Multiplies a currency

Parameters
Name Type Description
$value float|integer|\Zend_Currency

Multiplies this value from currency

$currency string|\Zend_Currency

The currency to multiply

Returns
Type Description
\Zend_Currency
methodpublicremoveCache( ) : void
static

Removes any set cache

methodpublicsetCache( \Zend_Cache_Core $cache ) : void
static

Sets a cache for Zend_Currency

Parameters
Name Type Description
$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
Name Type Description
$options array

(Optional) Options to set

Returns
Type Description
\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
Name Type Description
$locale string|\Zend_Locale

(Optional) Locale for parsing input

Returns
Type Description
\Zend_Currency Provides fluent interface
Throws
Exception Description
\Zend_Currency_Exception When the given locale does not exist
methodpublicsetService( string|\Zend_Currency_CurrencyInterface $service ) : \Zend_Currency

Sets a new exchange service

Parameters
Name Type Description
$service string|\Zend_Currency_CurrencyInterface

Service class

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

Adds a currency

Parameters
Name Type Description
$value float|integer|\Zend_Currency

Add this value to currency

$currency string|\Zend_Currency

The currency to add

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

Substracts a currency

Parameters
Name Type Description
$value float|integer|\Zend_Currency

Substracts this value from currency

$currency string|\Zend_Currency

The currency to substract

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

Returns a localized currency string

Parameters
Name Type Description
$value integer|float

OPTIONAL Currency value

$options array

OPTIONAL options to set temporary

Returns
Type Description
string
Throws
Exception Description
\Zend_Currency_Exception When the value is not a number
methodpublictoString( ) : string

Returns the actual currency name

Returns
Type Description
string
Documentation was generated by DocBlox 0.15.1.