Documentation

NumberFormatter extends BaseFormatter
in package

Table of Contents

Constants

NUMBER_REGEX  = '/(0+)(\.?)(0*)/'

Methods

areThousandsRequired()  : bool
Find out if we need thousands separator This is indicated by a comma enclosed by a digit placeholders: #, 0 or ?
f2s()  : string
floatStringConvertScientific()  : string
format()  : string
padValue()  : string
scaleThousandsMillions()  : int
Scale thousands, millions,... This is indicated by a number of commas after a digit placeholder: #, or 0.0,, or ?,.
adjustSeparators()  : string
stripQuotes()  : string
complexNumberFormatMask()  : string
formatStraightNumericValue()  : string
makeString()  : string
mergeComplexNumberFormatMasks()  : array<string|int, mixed>
pregReplace()  : string
processComplexNumberFormatMask()  : string

Constants

Methods

areThousandsRequired()

Find out if we need thousands separator This is indicated by a comma enclosed by a digit placeholders: #, 0 or ?

public static areThousandsRequired(string &$format) : bool
Parameters
$format : string
Return values
bool

f2s()

public static f2s(float $f) : string
Parameters
$f : float
Return values
string

floatStringConvertScientific()

public static floatStringConvertScientific(string $s) : string
Parameters
$s : string
Return values
string

format()

public static format(float|int|numeric-string $value, string $format) : string
Parameters
$value : float|int|numeric-string

value to be formatted

$format : string
Return values
string

padValue()

public static padValue(string $value, string $baseFormat) : string
Parameters
$value : string
$baseFormat : string
Return values
string

scaleThousandsMillions()

Scale thousands, millions,... This is indicated by a number of commas after a digit placeholder: #, or 0.0,, or ?,.

public static scaleThousandsMillions(string &$format) : int
Parameters
$format : string
Return values
int

adjustSeparators()

protected static adjustSeparators(string $value) : string
Parameters
$value : string
Return values
string

stripQuotes()

protected static stripQuotes(string $format) : string
Parameters
$format : string
Return values
string

complexNumberFormatMask()

private static complexNumberFormatMask(mixed $number, string $mask[, bool $splitOnPoint = true ]) : string
Parameters
$number : mixed
$mask : string
$splitOnPoint : bool = true
Return values
string

formatStraightNumericValue()

private static formatStraightNumericValue(mixed $value, string $format, array<string|int, mixed> $matches, bool $useThousands) : string
Parameters
$value : mixed
$format : string
$matches : array<string|int, mixed>
$useThousands : bool
Return values
string

makeString()

private static makeString(array<string|int, mixed>|string $value) : string
Parameters
$value : array<string|int, mixed>|string
Return values
string

mergeComplexNumberFormatMasks()

private static mergeComplexNumberFormatMasks(array<string|int, mixed> $numbers, array<string|int, mixed> $masks) : array<string|int, mixed>
Parameters
$numbers : array<string|int, mixed>
$masks : array<string|int, mixed>
Return values
array<string|int, mixed>

pregReplace()

private static pregReplace(string $pattern, string $replacement, string $subject) : string
Parameters
$pattern : string
$replacement : string
$subject : string
Return values
string

processComplexNumberFormatMask()

private static processComplexNumberFormatMask(mixed $number, string $mask) : string
Parameters
$number : mixed
$mask : string
Return values
string

        
On this page

Search results