Currency extends Number
Table of Contents
- LEADING_SYMBOL = true
- SYMBOL_WITH_SPACING = true
- SYMBOL_WITHOUT_SPACING = false
- TRAILING_SYMBOL = false
- WITH_THOUSANDS_SEPARATOR = true
- WITHOUT_THOUSANDS_SEPARATOR = false
- MAX_DECIMALS = 30
- $currencyCode : string
- $currencySymbolPosition : bool
- $currencySymbolSpacing : bool
- $decimals : int
- $fullLocale : string|null
- $locale : string|null
- $localeFormat : string|null
- $thousandsSeparator : bool
- __construct() : mixed
- __toString() : string
- format() : string
- setCurrencyCode() : void
- setCurrencySymbolPosition() : void
- setCurrencySymbolSpacing() : void
- setDecimals() : void
- setLocale() : void
- Setting a locale will override any settings defined in this class.
- setThousandsSeparator() : void
- getLocaleFormat() : string
- As MS Excel cannot easily handle Lakh, which is the only locale-specific Number format variant, we don't use locale with Numbers.
- formatCurrencyCode() : string
- validateLocale() : string
Constants
LEADING_SYMBOL
public
mixed
LEADING_SYMBOL
= true
SYMBOL_WITH_SPACING
public
mixed
SYMBOL_WITH_SPACING
= true
SYMBOL_WITHOUT_SPACING
public
mixed
SYMBOL_WITHOUT_SPACING
= false
TRAILING_SYMBOL
public
mixed
TRAILING_SYMBOL
= false
WITH_THOUSANDS_SEPARATOR
public
mixed
WITH_THOUSANDS_SEPARATOR
= true
WITHOUT_THOUSANDS_SEPARATOR
public
mixed
WITHOUT_THOUSANDS_SEPARATOR
= false
MAX_DECIMALS
protected
mixed
MAX_DECIMALS
= 30
Properties
$currencyCode
protected
string
$currencyCode
= '$'
$currencySymbolPosition
protected
bool
$currencySymbolPosition
= self::LEADING_SYMBOL
$currencySymbolSpacing
protected
bool
$currencySymbolSpacing
= self::SYMBOL_WITHOUT_SPACING
$decimals
protected
int
$decimals
= 2
$fullLocale
protected
string|null
$fullLocale
= null
$locale
protected
string|null
$locale
= null
$localeFormat
protected
string|null
$localeFormat
= null
$thousandsSeparator
protected
bool
$thousandsSeparator
= true
Methods
__construct()
public
__construct([string $currencyCode = '$' ][, int $decimals = 2 ][, bool $thousandsSeparator = true ][, bool $currencySymbolPosition = self::LEADING_SYMBOL ][, bool $currencySymbolSpacing = self::SYMBOL_WITHOUT_SPACING ][, string|null $locale = null ]) : mixed
Parameters
- $currencyCode : string = '$'
-
the currency symbol or code to display for this mask
- $decimals : int = 2
-
number of decimal places to display, in the range 0-30
- $thousandsSeparator : bool = true
-
indicator whether the thousands separator should be used, or not
- $currencySymbolPosition : bool = self::LEADING_SYMBOL
-
indicates whether the currency symbol comes before or after the value Possible values are Currency::LEADING_SYMBOL and Currency::TRAILING_SYMBOL
- $currencySymbolSpacing : bool = self::SYMBOL_WITHOUT_SPACING
-
indicates whether there is spacing between the currency symbol and the value Possible values are Currency::SYMBOL_WITH_SPACING and Currency::SYMBOL_WITHOUT_SPACING
- $locale : string|null = null
-
Set the locale for the currency format; or leave as the default null. If provided, Locale values must be a valid formatted locale string (e.g. 'en-GB', 'fr', uz-Arab-AF). Note that setting a locale will override any other settings defined in this class other than the currency code; or decimals (unless the decimals value is set to 0).
Tags
Return values
mixed —__toString()
public
__toString() : string
Return values
string —format()
public
format() : string
Return values
string —setCurrencyCode()
public
setCurrencyCode(string $currencyCode) : void
Parameters
- $currencyCode : string
Return values
void —setCurrencySymbolPosition()
public
setCurrencySymbolPosition([bool $currencySymbolPosition = self::LEADING_SYMBOL ]) : void
Parameters
- $currencySymbolPosition : bool = self::LEADING_SYMBOL
Return values
void —setCurrencySymbolSpacing()
public
setCurrencySymbolSpacing([bool $currencySymbolSpacing = self::SYMBOL_WITHOUT_SPACING ]) : void
Parameters
- $currencySymbolSpacing : bool = self::SYMBOL_WITHOUT_SPACING
Return values
void —setDecimals()
public
setDecimals([int $decimals = 2 ]) : void
Parameters
- $decimals : int = 2
Return values
void —setLocale()
Setting a locale will override any settings defined in this class.
public
setLocale([string|null $locale = null ]) : void
Parameters
- $locale : string|null = null
Tags
Return values
void —setThousandsSeparator()
public
setThousandsSeparator([bool $thousandsSeparator = self::WITH_THOUSANDS_SEPARATOR ]) : void
Parameters
- $thousandsSeparator : bool = self::WITH_THOUSANDS_SEPARATOR
Return values
void —getLocaleFormat()
As MS Excel cannot easily handle Lakh, which is the only locale-specific Number format variant, we don't use locale with Numbers.
protected
getLocaleFormat() : string
Return values
string —formatCurrencyCode()
private
formatCurrencyCode() : string
Return values
string —validateLocale()
private
validateLocale(string $locale) : string
Parameters
- $locale : string