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
NUMBER_REGEX
private
mixed
NUMBER_REGEX
= '/(0+)(\.?)(0*)/'
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
boolf2s()
public
static f2s(float $f) : string
Parameters
- $f : float
Return values
stringfloatStringConvertScientific()
public
static floatStringConvertScientific(string $s) : string
Parameters
- $s : string
Return values
stringformat()
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
stringpadValue()
public
static padValue(string $value, string $baseFormat) : string
Parameters
- $value : string
- $baseFormat : string
Return values
stringscaleThousandsMillions()
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
intadjustSeparators()
protected
static adjustSeparators(string $value) : string
Parameters
- $value : string
Return values
stringstripQuotes()
protected
static stripQuotes(string $format) : string
Parameters
- $format : string
Return values
stringcomplexNumberFormatMask()
private
static complexNumberFormatMask(mixed $number, string $mask[, bool $splitOnPoint = true ]) : string
Parameters
- $number : mixed
- $mask : string
- $splitOnPoint : bool = true
Return values
stringformatStraightNumericValue()
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
stringmakeString()
private
static makeString(array<string|int, mixed>|string $value) : string
Parameters
- $value : array<string|int, mixed>|string
Return values
stringmergeComplexNumberFormatMasks()
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
stringprocessComplexNumberFormatMask()
private
static processComplexNumberFormatMask(mixed $number, string $mask) : string
Parameters
- $number : mixed
- $mask : string