26 public static function DOLLAR($value = 0, $decimals = 2): string
32 if (!is_numeric($value) || !is_numeric($decimals)) {
35 $decimals = (int) $decimals;
39 $mask .=
'.' . str_repeat(
'0', $decimals);
41 $round = 10 ** abs($decimals);
47 $mask =
"{$mask};-{$mask}";
59 public static function FIXEDFORMAT($value, $decimals = 2, $noCommas =
false): string
66 if (!is_numeric($value) || !is_numeric($decimals)) {
69 $decimals = (float) $decimals;
70 $value = (float) $value;
71 $decimals = (int) floor($decimals);
73 $valueResult = round($value, $decimals);
77 if ($noCommas ===
false) {
78 $valueResult = number_format(
86 return (
string) $valueResult;
100 if ((is_string($value)) && (!is_numeric($value)) && Date::isDateTimeFormatCode(
$format)) {
114 public static function VALUE($value =
'')
118 if (!is_numeric($value)) {
119 $numberValue = str_replace(
124 if (is_numeric($numberValue)) {
125 return (
float) $numberValue;
131 if (strpos($value,
':') !==
false) {
150 return (
float) $value;
162 public static function NUMBERVALUE($value =
'', $decimalSeparator = null, $groupSeparator = null)
168 if (!is_numeric($value)) {
172 $decimalPositions = preg_match_all(
'/' . preg_quote($decimalSeparator) .
'/', $value, $matches, PREG_OFFSET_CAPTURE);
173 if ($decimalPositions > 1) {
176 $decimalOffset = array_pop($matches[0])[1];
177 if (strpos($value, $groupSeparator, $decimalOffset) !==
false) {
181 $value = str_replace([$groupSeparator, $decimalSeparator], [
'',
'.'], $value);
184 $percentageString = rtrim($value,
'%');
185 if (!is_numeric($percentageString)) {
189 $percentageAdjustment = strlen($value) - strlen($percentageString);
190 if ($percentageAdjustment) {
191 $value = (float) $percentageString;
192 $value /= 10 ** ($percentageAdjustment * 2);
196 return (
float) $value;
static DOLLAR($value=0, $decimals=2)
DOLLAR.
static NUMBERVALUE($value='', $decimalSeparator=null, $groupSeparator=null)
NUMBERVALUE.
static getReturnDateType()
Return the current Return Date Format for functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object).
static setReturnDateType($returnDateType)
Set the Return Date Format used by functions that return a date/time (Excel, PHP Serialized Numeric o...
static getCurrencyCode()
Get the currency code.
static VALUE($value='')
VALUE.
static multiple($number, $multiple)
MROUND.
static fromString($dateValue)
DATEVALUE.
static TEXTFORMAT($value, $format)
TEXTFORMAT.
static FIXEDFORMAT($value, $decimals=2, $noCommas=false)
FIXEDFORMAT.
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.
static getThousandsSeparator()
Get the thousands separator.
static getDecimalSeparator()
Get the decimal separator.
static fromString($timeValue)
TIMEVALUE.