private function castToGuessedDataType(string $value)
    {
        $stringValueWithoutQuotes = $this->removeEncapsulatingQuotes($value);
        if ($stringValueWithoutQuotes !== null) {
            return $stringValueWithoutQuotes;
        }

        $intValue = filter_var($value, FILTER_VALIDATE_INT, []);
        if ($intValue !== false) {
            return $intValue;
        }

        $floatValue = filter_var($value, FILTER_VALIDATE_FLOAT, []);
        if ($floatValue !== false) {
            return $floatValue;
        }

        $boolValue = filter_var($value, FILTER_VALIDATE_BOOLEAN, ['flags' => FILTER_NULL_ON_FAILURE]);
        if ($boolValue !== null) {
            return $boolValue;
        }

        return $value;
    }
private function castToGuessedDataType(string $value)
    {
        $stringValueWithoutQuotes = $this->removeEncapsulatingQuotes($value);
        if ($stringValueWithoutQuotes !== null) {
            return $stringValueWithoutQuotes;
        }

        $intValue = filter_var($value, FILTER_VALIDATE_INT, []);
        if ($intValue !== false) {
            return $intValue;
        }

        $floatValue = filter_var($value, FILTER_VALIDATE_FLOAT, []);
        if ($floatValue !== false) {
            return $floatValue;
        }

        $boolValue = filter_var($value, FILTER_VALIDATE_BOOLEAN, ['flags' => FILTER_NULL_ON_FAILURE]);
        if ($boolValue !== null) {
            return $boolValue;
        }

        return $value;
    }
private function castToGuessedDataType ( string $ value ) { $ stringValueWithoutQuotes = $ this -> removeEncapsulatingQuotes ( $ value ) ; if ( $ stringValueWithoutQuotes !== null ) { return $ stringValueWithoutQuotes ; } $ intValue = filter_var ( $ value , FILTER_VALIDATE_INT , [ ] ) ; if ( $ intValue !== false ) { return $ intValue ; } $ floatValue = filter_var ( $ value , FILTER_VALIDATE_FLOAT , [ ] ) ; if ( $ floatValue !== false ) { return $ floatValue ; } $ boolValue = filter_var ( $ value , FILTER_VALIDATE_BOOLEAN , [ 'flags' => FILTER_NULL_ON_FAILURE ] ) ; if ( $ boolValue !== null ) { return $ boolValue ; } return $ value ; }
Guess most appropriate data type acceptable by JSON
Guess most appropriate data type acceptable by JSON