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

Method floatvalue

lib/Service/StorageService.php:304–319  ·  view source on GitHub ↗
($val)

Source from the content-addressed store, hash-verified

302 }
303
304 private function floatvalue($val) {
305 // if value is a 3 digit comma number with one leading zero like 0,111, it should not go through the 1000 separator removal
306 if (preg_match('/(?<=\b0),(?=\d{3}\b)/', $val) === 1 && preg_match('/(?<=\b0).(?=\d{3}\b)/', $val) === 1) {
307 // remove , as 1000 separator
308 $val = preg_replace('/(?<=\d)\,(?=\d{3}\b)/', '', $val);
309 // remove . as 1000 separator
310 $val = preg_replace('/(?<=\d)\.(?=\d{3}\b)/', '', $val);
311 }
312 // convert remaining comma to decimal point
313 $val = str_replace(",", ".", $val);
314 if (is_numeric($val)) {
315 return number_format(floatval($val), 2, '.', '');
316 } else {
317 return false;
318 }
319 }
320
321 private function convertGermanDateFormat($val) {
322 if ($val !== null) {

Callers 1

updateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected