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

Method floatvalue

lib/Service/ReportService.php:661–676  ·  view source on GitHub ↗
($val)

Source from the content-addressed store, hash-verified

659 }
660
661 private function floatvalue($val) {
662 // if value is a 3 digit comma number with one leading zero like 0,111, it should not go through the 1000 separator removal
663 if (preg_match('/(?<=\b0)\,(?=\d{3}\b)/', $val) === 0 && preg_match('/(?<=\b0)\.(?=\d{3}\b)/', $val) === 0) {
664 // remove , as 1000 separator
665 $val = preg_replace('/(?<=\d)\,(?=\d{3}\b)/', '', $val);
666 // remove . as 1000 separator
667 $val = preg_replace('/(?<=\d)\.(?=\d{3}\b)/', '', $val);
668 }
669 // convert remaining comma to decimal point
670 $val = str_replace(",", ".", $val);
671 if (is_numeric($val)) {
672 return number_format(floatval($val), 2, '.', '');
673 } else {
674 return false;
675 }
676 }
677
678}

Callers 1

importMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected