获取过滤变量下标的帮助函数

@link https://github.com/soliphp/helpers#sanitize

@param array $source
@param string $name 变量下标
@param string $filter sanitize 方法中的过滤标识
@param mixed $default 默认值
@return mixed
766571
protected function getHelper(array $source, $name = null, $filter = null, $default = null)
    {
        if (empty($name)) {
            return $source;
        }

        if (!isset($source[$name])) {
            return $default;
        }

        $value = $source[$name];
        if ($filter !== null) {
            $value = sanitize($value, $filter);
        }

        return $value;
    }
729078
public function filter($key, $default = NULL, $filter = FILTER_DEFAULT, $options = array()) {

		$value = $this->get($key, $default);

		// Always turn $options into an array - this allows filter_var option shortcuts.

		if (!is_array($options) && $options) {
			$options = array('flags' => $options);
		}

		// Add a convenience check for arrays.

		if (is_array($value) && !isset($options['flags'])) {
			$options['flags'] = FILTER_REQUIRE_ARRAY;
		}

		return filter_var($value, $filter, $options);

	}
256695
public function getConst($name, $sanitize = null)
    {
        return $this->sanitize(ArrayHelper::getValue(static::$constants, $name), $sanitize);
    }
199202
public static function get($name, $default = '') {
        $_GET = self::paramFilter($_GET);
        if (isset($_GET[$name])) {
            if (empty($_GET[$name])) {
                return $default;
            }
            return $_GET[$name];
        }
        return false;
    }
625949
public function get($name = '', $default = null, $filter = null) {
        $value = $_GET;
        if ($name) {
            $value = $value[ $name ];
        }
        return $this->value($value, $default, $filter);
    }
397110
public function getExtension($name, array $params = [], $sanitize = null)
    {
        $result = $this->_getExtensionInternal($name, $params);
        if (!empty($params)) {
            $this->removePlaceholder('params');
        }

        return $this->sanitize($result, $sanitize);
    }
952543
public static function getFormValue($name, $default='')
    {
        $val = filter_input(INPUT_GET, $name, FILTER_CALLBACK, array('options'=>array('COREPOS\\common\\FormLib', 'filterCallback')));
        if ($val === null) {
            $val = filter_input(INPUT_POST, $name, FILTER_CALLBACK, array('options'=>array('COREPOS\\common\\FormLib', 'filterCallback')));
        }
        if ($val === null) {
            $val = $default;
        }

        return $val;
    }
580478
public function setDefaultFilter($name)
    {
        if (!\array_key_exists($name, $this->filters)) {
            throw new \InvalidArgumentException(sprintf('Cannot set default exception filter "%s". It does not exist.', $name));
        }

        $this->defaultFilter = $name;
    }
524737
public static function get(string $name, $default = null)
    {
        $value = getenv($name);

        if ($value === false) {
            return static::value($default);
        }

        switch (strtolower($value)) {
            case 'true':
            case '(true)':
                return true;

            case 'false':
            case '(false)':
                return false;

            case 'null':
            case '(null)':
                return null;
        }

        return static::sanitise($value);
    }
264616
public function data($name, $filter = FILTER_DEFAULT, $flag = NULL) {
        $data = $flag ? filter_input(INPUT_POST, $name, $filter, $flag) : filter_input(INPUT_POST, $name, $filter);
        return $data;
    }
470106
private function getFilter(array $filters, $name, $default = null)
    {
        if ($this->hasFilter($filters, $name)) {
            return $filters[$name];
        }

        return $default;
    }
623779
public static function addFilter(array $filters, array $filterArray, string $key, string $name): array
    {
        if (isset($filterArray[$name][$key])) {
            unset($filterArray[$name][$key]);
        }
        if (sizeof($filterArray[$name]) > 0) {
            $filters['filter']['bool']['must'][] = $filterArray;
        }

        return $filters;
    }
483736
public function get($name, $sanitize = true, $array = false)
    {
        $filter = 0;
        $flags  = FILTER_FLAG_EMPTY_STRING_NULL | FILTER_NULL_ON_FAILURE;

        if ($sanitize) {
            $filter = $filter | FILTER_SANITIZE_STRING;
            $flags  = $flags | FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH;
        }
        if ($array) {
            $flags = $flags | FILTER_REQUIRE_ARRAY | FILTER_FORCE_ARRAY;
        }

        if (empty($name)) {
            $result = array();

            foreach ($this->data as $key => $value) {
                $result[$key] = filter_var($value, $filter, array('flags' => $flags));
            }

            return $result;
        }

        if (!isset($this->data[$name])) {
            return $array ? array() : null;
        }

        return filter_var($this->data[$name], $filter, array('flags' => $flags));
    }
722799
public function getPosted($name, $default = null, $filter = true, $type = 'string')
    {
        return $this->request->post($name, $default, $filter, $type);
    }
830632
public function getBoolean($name, $default = '', $verb = 'get', $options = array())
    {
        //FILTER_SANITIZE_NUMBER_INT
        $filter = \IS\BOOLEAN;
        $options = array(
            "options" => $options
        );

        $boolean = $this->getVar($name, $filter, $default, $verb, $options);

        //@TODO valid is float before return

        return (boolean)$boolean;
    }
366894
public function server($name = "", $default = null, $filter = null) {
        if (empty($this->server)) {
            $this->server = $_SERVER;
        }
        if (!$name) {
            $value = $this->server;
        } else {
            $value = $this->server[ $name ];
        }
        return $this->value($value, $default, $filter);
    }
1245651
protected function getParam($name, $filters = null) {
        $params = $this->getParams();
        if(property_exists($params, $name)) {
            $value = $params->$name;
            if(!is_null($filters)) {
                $value = $this->getFilter()->sanitize($value, $filters);
            }
            return $value;
        } else {
            throw new ParamNotFoundException('Param Not Found: ' . $name);
        }
    }