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

Method floatvalue

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

Source from the content-addressed store, hash-verified

781 }
782
783 private function floatvalue($val)
784 {
785 // if value is a 3 digit comma number with one leading zero like 0,111, it should not go through the 1000 separator removal
786 if (preg_match('/(?<=\b0)\,(?=\d{3}\b)/', $val) === 0 && preg_match('/(?<=\b0)\.(?=\d{3}\b)/', $val) === 0) {
787 // remove , as 1000 separator
788 $val = preg_replace('/(?<=\d)\,(?=\d{3}\b)/', '', $val);
789 // remove . as 1000 separator
790 $val = preg_replace('/(?<=\d)\.(?=\d{3}\b)/', '', $val);
791 }
792 // convert remaining comma to decimal point
793 $val = str_replace(",", ".", $val);
794 if (is_numeric($val)) {
795 return number_format(floatval($val), 2, '.', '');
796 } else {
797 return false;
798 }
799 }
800
801}

Callers 2

updateDataMethod · 0.95
importClipboardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected