src/LearnositySdk/Utils/Json.php
private static function getFloatMap($value)
    {
        if (!is_float($value)) {
            return [];
        }

        $stringValue = json_encode($value);

        // If the string value is in scientific notation it should have a negative exponent. Split it there.
        $explodedValue = explode('E-', strtoupper($stringValue));
        if (count($explodedValue) === 2) {
            // The second entry tells us how many decimal places are created via the exponent
            $decimalsFromExponent = (int)$explodedValue[1];

            // The base hase the form x.xxxxx where x is any digit. We need to get the number of decimals after
            // the dot
            $decimalsFromBase = 0;
            $explodedBase = explode('.', $explodedValue[0]);
            if (count($explodedBase) === 2) {
                $decimalsFromBase = strlen($explodedBase[1]);
            }
            $totalDecimals = $decimalsFromBase + $decimalsFromExponent;
            $stringValueAsFloat = number_format($value, $totalDecimals);
            return [
                $stringValue => $stringValueAsFloat
            ];
        }
        return [];
    }
private static function getFloatMap($value)
    {
        if (!is_float($value)) {
            return [];
        }

        $stringValue = json_encode($value);

        // If the string value is in scientific notation it should have a negative exponent. Split it there.
        $explodedValue = explode('E-', strtoupper($stringValue));
        if (count($explodedValue) === 2) {
            // The second entry tells us how many decimal places are created via the exponent
            $decimalsFromExponent = (int)$explodedValue[1];

            // The base hase the form x.xxxxx where x is any digit. We need to get the number of decimals after
            // the dot
            $decimalsFromBase = 0;
            $explodedBase = explode('.', $explodedValue[0]);
            if (count($explodedBase) === 2) {
                $decimalsFromBase = strlen($explodedBase[1]);
            }
            $totalDecimals = $decimalsFromBase + $decimalsFromExponent;
            $stringValueAsFloat = number_format($value, $totalDecimals);
            return [
                $stringValue => $stringValueAsFloat
            ];
        }
        return [];
    }
private static function getFloatMap ( $ value ) { if ( ! is_float ( $ value ) ) { return [ ] ; } $ stringValue = json_encode ( $ value ) ; // If the string value is in scientific notation it should have a negative exponent. Split it there. $ explodedValue = explode ( 'E-' , strtoupper ( $ stringValue ) ) ; if ( count ( $ explodedValue ) === 2 ) { // The second entry tells us how many decimal places are created via the exponent $ decimalsFromExponent = ( int ) $ explodedValue [ 1 ] ; // The base hase the form x.xxxxx where x is any digit. We need to get the number of decimals after // the dot $ decimalsFromBase = 0 ; $ explodedBase = explode ( '.' , $ explodedValue [ 0 ] ) ; if ( count ( $ explodedBase ) === 2 ) { $ decimalsFromBase = strlen ( $ explodedBase [ 1 ] ) ; } $ totalDecimals = $ decimalsFromBase + $ decimalsFromExponent ; $ stringValueAsFloat = number_format ( $ value , $ totalDecimals ) ; return [ $ stringValue => $ stringValueAsFloat ] ; } return [ ] ; }
Helper function to build up the float map

@param $value
@return array
Helper function to build up the float map