NumericHelper
in package
Utility class for work with numbers
Table of Contents
Methods
- Format() : string
- Formats a numeric value as a string with customizable decimal and thousands separators.
- Humanize() : string
- Normalize() : float
- Normalizes a given input (string or other data) and returns a floating-point value.
- ToMoney() : string
- Converts a numeric value to a formatted money string.
Methods
Format()
Formats a numeric value as a string with customizable decimal and thousands separators.
public
static Format(float $number[, string $decPoint = '.' ][, int $deccount = 2 ][, bool $removeLeadingZeroes = false ][, string $thousandsSep = '' ]) : string
Parameters
- $number : float
-
The numeric value to format.
- $decPoint : string = '.'
-
The decimal point character (optional, default is '.').
- $deccount : int = 2
-
The number of decimal places (optional, default is 2).
- $removeLeadingZeroes : bool = false
-
Whether to remove leading zeroes (optional, default is false).
- $thousandsSep : string = ''
-
The thousands separator (optional, default is '').
Return values
string —The formatted numeric value as a string.
Humanize()
public
static Humanize(float $price) : string
Parameters
- $price : float
Tags
Return values
stringNormalize()
Normalizes a given input (string or other data) and returns a floating-point value.
public
static Normalize(mixed $string) : float
Parameters
- $string : mixed
-
The input data to be normalized.
Return values
float —The normalized value as a floating-point number.
ToMoney()
Converts a numeric value to a formatted money string.
public
static ToMoney(float $number) : string
Parameters
- $number : float
-
The numeric value to convert.
Return values
string —The money representation of the input value.