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

Method floatvalue

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

Source from the content-addressed store, hash-verified

799 }
800
801 private function floatvalue($val)
802 {
803 // if value is a 3 digit comma number with one leading zero like 0,111, it should not go through the 1000 separator removal
804 if (preg_match('/(?<=\b0)\,(?=\d{3}\b)/', $val) === 0 && preg_match('/(?<=\b0)\.(?=\d{3}\b)/', $val) === 0) {
805 // remove , as 1000 separator
806 $val = preg_replace('/(?<=\d)\,(?=\d{3}\b)/', '', $val);
807 // remove . as 1000 separator
808 $val = preg_replace('/(?<=\d)\.(?=\d{3}\b)/', '', $val);
809 }
810 // convert remaining comma to decimal point
811 $val = str_replace(",", ".", $val);
812 if (is_numeric($val)) {
813 return number_format(floatval($val), 2, '.', '');
814 } else {
815 return false;
816 }
817 }
818
819}

Callers 2

updateDataMethod · 0.95
importClipboardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected