Contentserv PHP API

CSNumberFormats
in package

This class provides all kinds of API methods for the number formats.

Tags
since

CS22.4

Table of Contents

NUMBER_FORMAT_COMMA  = '####,##'
NUMBER_FORMAT_COMMA_POINT  = '#.###,##'
NUMBER_FORMAT_COMMA_SPACE  = '# ###,##'
NUMBER_FORMAT_POINT  = '####.##'
Defines the available and allowed number formats.
NUMBER_FORMAT_POINT_APOSTROPHE  = "#'###.##"
NUMBER_FORMAT_POINT_COMMA  = '#,###.##'
NUMBER_FORMAT_POINT_SPACE  = '# ###.##'
SEPARATOR_APOSTROPHE  = "'"
SEPARATOR_COMMA  = ','
SEPARATOR_NONE  = ''
Defines the separators in the number formats.
SEPARATOR_POINT  = '.'
SEPARATOR_SPACE  = ' '
formatNumber()  : array<string|int, mixed>|string|array<string|int, string>
Formats a given number value with the given separators.
formatNumberInFormat()  : string
Formats a given number value for the given number format and the number of decimals.
getAvailableNumberFormats()  : array<string|int, CSNumberFormat>|array<string|int, string>
Returns an array with the available number format objects or strings.
getDecimalSeparatorLabels()  : array<string|int, mixed>
Returns all available decimal separators.
getNumberFormat()  : CSNumberFormat
Returns a number format API object.
getNumberFormatForLanguage()  : CSNumberFormat
Returns the number format API object for a given language id.
getNumberFormatForSeparators()  : CSNumberFormat|string
Returns the number format API object for the given separators.
getThousandSeparatorLabels()  : array<string|int, mixed>
Returns all available thousand separators.
guessNumberFormat()  : CSNumberFormat|null
This method tries to map the formatted value to a number format.

Constants

NUMBER_FORMAT_COMMA

public mixed NUMBER_FORMAT_COMMA = '####,##'
Tags

NUMBER_FORMAT_COMMA_POINT

public mixed NUMBER_FORMAT_COMMA_POINT = '#.###,##'
Tags

NUMBER_FORMAT_COMMA_SPACE

public mixed NUMBER_FORMAT_COMMA_SPACE = '# ###,##'
Tags

NUMBER_FORMAT_POINT

Defines the available and allowed number formats.

public string NUMBER_FORMAT_POINT = '####.##'
Tags

NUMBER_FORMAT_POINT_APOSTROPHE

public mixed NUMBER_FORMAT_POINT_APOSTROPHE = "#'###.##"
Tags

NUMBER_FORMAT_POINT_COMMA

public mixed NUMBER_FORMAT_POINT_COMMA = '#,###.##'
Tags

NUMBER_FORMAT_POINT_SPACE

public mixed NUMBER_FORMAT_POINT_SPACE = '# ###.##'
Tags

SEPARATOR_NONE

Defines the separators in the number formats.

public string SEPARATOR_NONE = ''
Tags

Methods

formatNumber()

Formats a given number value with the given separators.

public static formatNumber(int|float $mNumberValue[, CSNumberFormat|null $oNumberFormat = null ][, int|null $iDecimals = null ][, bool $bAddThousandSeparator = true ]) : array<string|int, mixed>|string|array<string|int, string>
Parameters
$mNumberValue : int|float

The value, which should be formatted.

$oNumberFormat : CSNumberFormat|null = null

The target number format.

$iDecimals : int|null = null

The number of decimals.

$bAddThousandSeparator : bool = true
Tags
Return values
array<string|int, mixed>|string|array<string|int, string>

formatNumberInFormat()

Formats a given number value for the given number format and the number of decimals.

public static formatNumberInFormat(mixed $mNumberValue[, CSNumberFormat|null $oNumberFormat = null ][, int|null $iDecimals = null ][, bool $bAddThousandSeparator = true ]) : string
Parameters
$mNumberValue : mixed

The value, which should be formatted.

$oNumberFormat : CSNumberFormat|null = null

The target number format.

$iDecimals : int|null = null

The number of decimals.

$bAddThousandSeparator : bool = true

Whether the thousand separator should be added or not.

Tags
Return values
string

getAvailableNumberFormats()

Returns an array with the available number format objects or strings.

public static getAvailableNumberFormats([bool $bReturnOnlyNumberFormatStrings = false ]) : array<string|int, CSNumberFormat>|array<string|int, string>
Parameters
$bReturnOnlyNumberFormatStrings : bool = false

Whether only the number format strings should be returned.

Tags
Return values
array<string|int, CSNumberFormat>|array<string|int, string>

getDecimalSeparatorLabels()

Returns all available decimal separators.

public static getDecimalSeparatorLabels(int $iLanguageId) : array<string|int, mixed>
Parameters
$iLanguageId : int
Tags
Return values
array<string|int, mixed>

getNumberFormat()

Returns a number format API object.

public static getNumberFormat([string $sNumberFormat = null ]) : CSNumberFormat
Parameters
$sNumberFormat : string = null

The target number format.

Tags
throws
CSException

if the given number format does not exist

Return values
CSNumberFormat

getNumberFormatForLanguage()

Returns the number format API object for a given language id.

public static getNumberFormatForLanguage([int|null $iLanguageId = null ]) : CSNumberFormat
Parameters
$iLanguageId : int|null = null

The target language id.

Tags
throws
CSException

if the given number format does not exist

Return values
CSNumberFormat

getNumberFormatForSeparators()

Returns the number format API object for the given separators.

public static getNumberFormatForSeparators(string $sDecimalSeparator[, string $sThousandSeparator = '' ]) : CSNumberFormat|string
Parameters
$sDecimalSeparator : string

The target decimal separator.

$sThousandSeparator : string = ''

The target thousand separator.

Tags
throws
CSException
Return values
CSNumberFormat|string

getThousandSeparatorLabels()

Returns all available thousand separators.

public static getThousandSeparatorLabels(mixed $iLanguageId) : array<string|int, mixed>
Parameters
$iLanguageId : mixed
Tags
Return values
array<string|int, mixed>

guessNumberFormat()

This method tries to map the formatted value to a number format.

public static guessNumberFormat(string $sValue) : CSNumberFormat|null
Parameters
$sValue : string

The formatted number.

Tags
access

public

Return values
CSNumberFormat|null

The matching number format if found, null otherwise


        

Search results