public static function getValueWithinItsType($value, $knownType = null)
    {
        if (is_int($value) || (!is_null($value) && in_array($knownType, array(
            'time',
            'positiveInteger',
            'unsignedLong',
            'unsignedInt',
            'short',
            'long',
            'int',
            'integer',
        ), true))) {
            return intval($value);
        } elseif (is_float($value) || (!is_null($value) && in_array($knownType, array(
            'float',
            'double',
            'decimal',
        ), true))) {
            return floatval($value);
        } elseif (is_bool($value) || (!is_null($value) && in_array($knownType, array(
            'bool',
            'boolean',
        ), true))) {
            return ($value === 'true' || $value === true || $value === 1 || $value === '1');
        }
        return $value;
    }
public static function getValueWithinItsType($value, $knownType = null)
    {
        if (is_int($value) || (!is_null($value) && in_array($knownType, array(
            'time',
            'positiveInteger',
            'unsignedLong',
            'unsignedInt',
            'short',
            'long',
            'int',
            'integer',
        ), true))) {
            return intval($value);
        } elseif (is_float($value) || (!is_null($value) && in_array($knownType, array(
            'float',
            'double',
            'decimal',
        ), true))) {
            return floatval($value);
        } elseif (is_bool($value) || (!is_null($value) && in_array($knownType, array(
            'bool',
            'boolean',
        ), true))) {
            return ($value === 'true' || $value === true || $value === 1 || $value === '1');
        }
        return $value;
    }
public static function getValueWithinItsType ( $ value , $ knownType = null ) { if ( is_int ( $ value ) || ( ! is_null ( $ value ) && in_array ( $ knownType , array ( 'time' , 'positiveInteger' , 'unsignedLong' , 'unsignedInt' , 'short' , 'long' , 'int' , 'integer' , ) , true ) ) ) { return intval ( $ value ) ; } elseif ( is_float ( $ value ) || ( ! is_null ( $ value ) && in_array ( $ knownType , array ( 'float' , 'double' , 'decimal' , ) , true ) ) ) { return floatval ( $ value ) ; } elseif ( is_bool ( $ value ) || ( ! is_null ( $ value ) && in_array ( $ knownType , array ( 'bool' , 'boolean' , ) , true ) ) ) { return ( $ value === 'true' || $ value === true || $ value === 1 || $ value === '1' ) ; } return $ value ; }
Returns the value with good type
@param mixed $value the value
@param string $knownType the value
@return mixed
Returns the value with good type