public static function smart( $value, $emptyValueIsNull = false )
    {
        if ( is_array( $value ) )
        {
            filter_var_array( $value, FILTER_SANITIZE_STRING );
        }

        switch ( getType( $value ) )
        {
            case 'double':
            case 'float':
                $_filter = FILTER_SANITIZE_NUMBER_FLOAT;
                break;

            case 'integer':
                $_filter = FILTER_SANITIZE_NUMBER_INT;
                break;

            case 'string':
                $_filter = FILTER_SANITIZE_STRING;
                break;

            default:
                $_filter = FILTER_DEFAULT;
                break;
        }

        $_result = filter_var( $value, $_filter );

        return $emptyValueIsNull && empty( $_result ) ? null : $_result;
    }