CRM_Utils_Number
in package
Class CRM_Utils_Number
Table of Contents
Methods
- createRandomDecimal() : float
- Create a random number with a given precision.
- createTruncatedDecimal() : float
- Given a number, coerce it to meet the precision requirement. If possible, it should keep the number as-is. If necessary, this may drop the least-significant digits and/or move the decimal place.
- formatLocaleNumeric() : string
- Format number for display according to the current or supplied locale.
- formatUnitSize() : int
- Convert a file size value from the formats allowed in php_ini to the number of bytes.
- getMaximumFileUploadSize() : float
- Get the maximum size permitted for a file upload.
Methods
createRandomDecimal()
Create a random number with a given precision.
public
static createRandomDecimal(array<string|int, mixed> $precision) : float
Parameters
- $precision : array<string|int, mixed>
-
(int $significantDigits, int $postDecimalDigits).
Tags
Return values
floatcreateTruncatedDecimal()
Given a number, coerce it to meet the precision requirement. If possible, it should keep the number as-is. If necessary, this may drop the least-significant digits and/or move the decimal place.
public
static createTruncatedDecimal(int|float $keyValue, array<string|int, mixed> $precision) : float
Parameters
- $keyValue : int|float
- $precision : array<string|int, mixed>
-
(int $significantDigits, int $postDecimalDigits).
Tags
Return values
floatformatLocaleNumeric()
Format number for display according to the current or supplied locale.
public
static formatLocaleNumeric(string $amount[, string $locale = NULL ]) : string
Note this should not be used in conjunction with any calls to replaceCurrencySeparators as this function already does that.
Parameters
- $amount : string
- $locale : string = NULL
Tags
Return values
stringformatUnitSize()
Convert a file size value from the formats allowed in php_ini to the number of bytes.
public
static formatUnitSize(string $size) : int
Parameters
- $size : string
Return values
intgetMaximumFileUploadSize()
Get the maximum size permitted for a file upload.
public
static getMaximumFileUploadSize() : float