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
- 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 ][, array<string|int, int> $attributes = [] ]) : 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
- $attributes : array<string|int, int> = []
-
Options passed to NumberFormatter::setAttribute see https://www.php.net/manual/en/class.numberformatter.php#intl.numberformatter-constants.unumberformatattribute
Return values
stringformatUnitSize()
public
static formatUnitSize(mixed $size) : int
use ini_parse_quantity
Parameters
- $size : mixed
Return values
intgetMaximumFileUploadSize()
Get the maximum size permitted for a file upload.
public
static getMaximumFileUploadSize() : float