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

Method floatvalue

lib/Service/DataloadService.php:598–614  ·  view source on GitHub ↗
($val)

Source from the content-addressed store, hash-verified

596 }
597
598 private function floatvalue($val)
599 {
600 // if value is a 3 digit comma number with one leading zero like 0,111, it should not go through the 1000 separator removal
601 if (preg_match('/(?<=\b0)\,(?=\d{3}\b)/', $val) === 0 && preg_match('/(?<=\b0)\.(?=\d{3}\b)/', $val) === 0) {
602 // remove , as 1000 separator
603 $val = preg_replace('/(?<=\d)\,(?=\d{3}\b)/', '', $val);
604 // remove . as 1000 separator
605 $val = preg_replace('/(?<=\d)\.(?=\d{3}\b)/', '', $val);
606 }
607 // convert remaining comma to decimal point
608 $val = str_replace(",", ".", $val);
609 if (is_numeric($val)) {
610 return number_format(floatval($val), 2, '.', '');
611 } else {
612 return false;
613 }
614 }
615
616}

Callers 2

updateDataMethod · 0.95
importClipboardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected