src/Budkit/Protocol/Input.php
public function getVar($name, $filter = '', $default = '', $verb = 'get', $options = array())
    {

        if (strtolower($verb) == 'request') {
            $verb = $this->getVerb();
        }
        //just form casting
        $verb = strtolower($verb);

        if (!($input = $this->data($verb))) {
            return $default;
        }

        //Undefined
        if (empty($name) || !isset($input) || !isset($input[$name])) {
            if (isset($default) && !empty($default)) {
                return $default;
            } else {
                return null; //nothing for that name;
            }
        }

        //Do we have a filter;
        if (!isset($filter) || !is_int($filter)) {
            //PHP warns against using gettype to get type,
            //but its much easier than running every is_* to determine type
            //so fo now we go with gettype;
            $type = gettype($input[$name]);

            switch ($type) {
                case "interger":
                    $filter = \IS\INTERGER;
                    break;
                case "float":
                case "double":
                    $filter = \IS\FLOAT;
                    $options = array(
                        "flags" => FILTER_FLAG_ALLOW_SCIENTIFIC | FILTER_FLAG_ALLOW_FRACTION | FILTER_FLAG_ALLOW_THOUSAND,
                        "options" => $options
                    );
                    break;
                case "string":
                    $filter = \IS\STRING;
                    $options = array(
                        "flags" => !FILTER_FLAG_STRIP_LOW,
                        "options" => $options
                    );
                    break;
                case "object": //@TODO,
                case "resource":
                case "NULL":
                case "unknown type":
                default:
                    $filter = \IS\RAW;
                    $options = array(
                        "flags" => !FILTER_FLAG_STRIP_LOW,
                        "options" => $options
                    );
                    break;
            }
        }
        //uhhhnrrr...
        $variable = $input[$name];

        //Pre treat;
        if (get_magic_quotes_gpc() && ($input[$name] != $default) && ($verb != 'files')) {
            $variable = stripslashes($input[$name]); //??
        }

        return $this->filter($variable, $filter, $options);
    }
public function getVar($name, $filter = '', $default = '', $verb = 'get', $options = array())
    {

        if (strtolower($verb) == 'request') {
            $verb = $this->getVerb();
        }
        //just form casting
        $verb = strtolower($verb);

        if (!($input = $this->data($verb))) {
            return $default;
        }

        //Undefined
        if (empty($name) || !isset($input) || !isset($input[$name])) {
            if (isset($default) && !empty($default)) {
                return $default;
            } else {
                return null; //nothing for that name;
            }
        }

        //Do we have a filter;
        if (!isset($filter) || !is_int($filter)) {
            //PHP warns against using gettype to get type,
            //but its much easier than running every is_* to determine type
            //so fo now we go with gettype;
            $type = gettype($input[$name]);

            switch ($type) {
                case "interger":
                    $filter = \IS\INTERGER;
                    break;
                case "float":
                case "double":
                    $filter = \IS\FLOAT;
                    $options = array(
                        "flags" => FILTER_FLAG_ALLOW_SCIENTIFIC | FILTER_FLAG_ALLOW_FRACTION | FILTER_FLAG_ALLOW_THOUSAND,
                        "options" => $options
                    );
                    break;
                case "string":
                    $filter = \IS\STRING;
                    $options = array(
                        "flags" => !FILTER_FLAG_STRIP_LOW,
                        "options" => $options
                    );
                    break;
                case "object": //@TODO,
                case "resource":
                case "NULL":
                case "unknown type":
                default:
                    $filter = \IS\RAW;
                    $options = array(
                        "flags" => !FILTER_FLAG_STRIP_LOW,
                        "options" => $options
                    );
                    break;
            }
        }
        //uhhhnrrr...
        $variable = $input[$name];

        //Pre treat;
        if (get_magic_quotes_gpc() && ($input[$name] != $default) && ($verb != 'files')) {
            $variable = stripslashes($input[$name]); //??
        }

        return $this->filter($variable, $filter, $options);
    }
public function getVar ( $ name , $ filter = '' , $ default = '' , $ verb = 'get' , $ options = array ( ) ) { if ( strtolower ( $ verb ) == 'request' ) { $ verb = $ this -> getVerb ( ) ; } //just form casting $ verb = strtolower ( $ verb ) ; if ( ! ( $ input = $ this -> data ( $ verb ) ) ) { return $ default ; } //Undefined if ( empty ( $ name ) || ! isset ( $ input ) || ! isset ( $ input [ $ name ] ) ) { if ( isset ( $ default ) && ! empty ( $ default ) ) { return $ default ; } else { return null ; //nothing for that name; } } //Do we have a filter; if ( ! isset ( $ filter ) || ! is_int ( $ filter ) ) { //PHP warns against using gettype to get type, //but its much easier than running every is_* to determine type //so fo now we go with gettype; $ type = gettype ( $ input [ $ name ] ) ; switch ( $ type ) { case "interger" : $ filter = \ IS \ INTERGER ; break ; case "float" : case "double" : $ filter = \ IS \ FLOAT ; $ options = array ( "flags" => FILTER_FLAG_ALLOW_SCIENTIFIC | FILTER_FLAG_ALLOW_FRACTION | FILTER_FLAG_ALLOW_THOUSAND , "options" => $ options ) ; break ; case "string" : $ filter = \ IS \ STRING ; $ options = array ( "flags" => ! FILTER_FLAG_STRIP_LOW , "options" => $ options ) ; break ; case "object" : //@TODO, case "resource" : case "NULL" : case "unknown type" : default : $ filter = \ IS \ RAW ; $ options = array ( "flags" => ! FILTER_FLAG_STRIP_LOW , "options" => $ options ) ; break ; } } //uhhhnrrr... $ variable = $ input [ $ name ] ; //Pre treat; if ( get_magic_quotes_gpc ( ) && ( $ input [ $ name ] != $ default ) && ( $ verb != 'files' ) ) { $ variable = stripslashes ( $ input [ $ name ] ) ; //?? } return $ this -> filter ( $ variable , $ filter , $ options ) ; }
Gets an input variable. Attempts to determine what its type is
and returns a sanitized type

@param string $name
@param interger $filter
@param string $verb
@param interger $flags
@param array $options
Gets an input variable . Attempts to determine what its type is and returns a sanitized type