MCPcopy Create free account
hub / github.com/Rello/analytics / floatvalue

Method floatvalue

lib/Service/ThresholdService.php:109–124  ·  view source on GitHub ↗
($val)

Source from the content-addressed store, hash-verified

107 }
108
109 private function floatvalue($val) {
110 // if value is a 3 digit comma number with one leading zero like 0,111, it should not go through the 1000 separator removal
111 if (preg_match('/(?<=\b0)\,(?=\d{3}\b)/', $val) === 0 && preg_match('/(?<=\b0)\.(?=\d{3}\b)/', $val) === 0) {
112 // remove , as 1000 separator
113 $val = preg_replace('/(?<=\d)\,(?=\d{3}\b)/', '', $val);
114 // remove . as 1000 separator
115 $val = preg_replace('/(?<=\d)\.(?=\d{3}\b)/', '', $val);
116 }
117 // convert remaining comma to decimal point
118 $val = str_replace(",", ".", $val);
119 if (is_numeric($val)) {
120 return number_format(floatval($val), 2, '.', '');
121 } else {
122 return false;
123 }
124 }
125
126 private function normalizeNumberString(string $str): string {
127 $str = trim($str);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected