字段过滤

@param  array $value
@param null   $default
@param null   $filter

@return mixed|null
776999
protected function value($value, $default = null, $filter = null) {
        if ($this->valueFilter == null) {
            $this->valueFilter = Ioc::get(ValueFilter::class);
        }
        if (is_array($value)) {
            $data = array();
            foreach ($value as $key => $val) {
                $data[ $key ] = $this->valueFilter->filter($val);
            }
            return $data;
        }
        if (!isset($value)) {
            $value = $default;
        }
        $value = $this->valueFilter->filter($value, $filter);
        return $value;
    }
309486
public function resolve($value, $default = 'value')
    {
        $callable = $this->getCallable($value);

        if (is_array($callable)) {
            if (is_callable($callable[0])) {
                return call_user_func_array($callable[0], $callable[1]);
            } else {
                return $callable[0];
            }
        }

        return $this->fallback->resolve($value, $default);
    }
586421
public function session($name = '', $default = null, $filter = '')
    {
        if (empty($this->session)) {
            $this->session = Session::get();
        }
        if (is_array($name)) {
            return $this->session = array_merge($this->session, $name);
        }
        return $this->input($this->session, $name, $default, $filter);
    }
691174
public function get($key, $default = null, $filter = null)
    {
        $result = $default;
        if ($this->has($key)) {
            $result = $this->offsetGet($key);
        }

        return $this->filter($result, $filter);
    }
988611
public function find($key, $default = null, $filter = null)
    {
        return $this->_store->get($key, $default, $filter);
    }
947296
public function filter($value)
    {
        return true === array_key_exists((string)$value, $this->translations) ? $this->translations[$value] : null;
    }
366610
public function getQueryParam($param, $default = null, $filter = null, $filterOptions = null)
    {
        $params = $this->getQueryParams();
        $value = isset($params[$param]) ? $params[$param] : $default;
        
        if (isset($filter) && isset($value)) {
            $value = filter_var($value, $filter, $filterOptions);
        }
        
        return $value;
    }
463998
public function _set_default_value( $value ) {
		if ( is_null( $value ) || false === $value ) {
			if ( isset( $this->args['default'] ) ) {
				return $this->args['default'];
			}
		}
		return $value;
	}
1127106
protected function filter($value, $filter)
    {
        if (null !== $filter) {
            $value = Filter::_($value, $filter);
        }

        return $value;
    }
378656
public function value($field, $default = null)
    {
        $result = null;
        if (!$result) {
            if (isset($this->options['field'])) {
                unset($this->options['field']);
            }
            $cursor = $this->field($field)->fetchCursor(true)->find();
            $cursor->setTypeMap(['root' => 'array']);
            $resultSet = $cursor->toArray();
            $data      = isset($resultSet[0]) ? $resultSet[0] : null;
            $result    = $data[$field];
        } else {
            // 清空查询条件
            $this->options = [];
        }
        return !is_null($result) ? $result : $default;
    }
831136
public function param($name = '', $default = null, $filter = '')
    {
        if (empty($this->param)) {
            $method = $this->method(true);
            // 自动获取请求变量
            switch ($method) {
                case 'POST':
                    $vars = $this->post(false);
                    break;
                case 'PUT':
                case 'DELETE':
                case 'PATCH':
                    $vars = $this->put(false);
                    break;
                default:
                    $vars = [];
            }
            // 当前请求参数和URL地址中的参数合并
            $this->param = array_merge($this->get(false), $vars, $this->route(false));
        }
        if (true === $name) {
            // 获取包含文件上传信息的数组
            $file = $this->file();
            $data = is_array($file) ? array_merge($this->param, $file) : $this->param;
            return $this->input($data, '', $default, $filter);
        }
        return $this->input($this->param, $name, $default, $filter);
    }
1134765
public static function arr($value, $filter = null): array
    {
        $array = (array)$value;

        if ($filter === 'noempty') {
            $array = Arr::clean($array);
        } elseif ($filter instanceof \Closure) {
            $array = array_filter($array, $filter); // TODO add support both - key + value
        }

        return $array;
    }
1277815
public function value($default = null)
    {
        $arguments = $this->command->arguments;

        if (is_array($arguments)) {
            return isset($arguments[$this->key]) ? $arguments[$this->key] : $default;
        }

        return $default;
    }
653244
public function config($value = null, $default = false)
        {
            // Setter
            if (Arrays::is($value)) {
                if (count($value) > 0) {
                    // Merge given config settings over any previous ones (if $value is array)
                    static::$cfg = $this->arrayMergeRecursiveReplace(static::$cfg, $value);
                }
            // Getter
            } else {
                // Config array is static to persist across multiple instances
                $cfg = static::$cfg;

                // No value passed - return entire config array
                if ($value === null) {
                    return $cfg;
                }

                // Find value to return
                if (strpos($value, '.') !== false) {
                    $cfgValue = $cfg;
                    $valueParts = explode('.', $value);

                    foreach($valueParts as $valuePart) {
                        if (isset($cfgValue[$valuePart])) {
                            $cfgValue = $cfgValue[$valuePart];
                        } else {
                            $cfgValue = $default;
                        }
                    }
                } else {
                    $cfgValue = $cfg;

                    if (isset($cfgValue[$value])) {
                        $cfgValue = $cfgValue[$value];
                    } else {
                        $cfgValue = $default;
                    }
                }

                return $cfgValue;
            }
        }
330933
public static function common(string $filter, ...$value)
	{
		if (method_exists(__CLASS__, $filter)) {
			return self::$filter(...$value);
		}
		return null;
	}
15260
public function filter($value) {
    	    	
    	$value   = str_replace(["\r", "\r\n", "\n"], '', $value);
    	$decoded = json_decode($value,true);
    	if(is_null($decoded)){
    		return null;
    	}    	
    	
    	switch($this->options["format"]){
    	    case self::DECODED:
    	        return $decoded;
    	    case self::JSON:
    	        return $value;
    	    case self::SERIALIZED:
    	        return serialize($decoded);
    	    default:
    	        throw new FilterException("unknown format for JSON filter specified");
    	}
    }
388070
public static function Arr($array, $filter = null, $default = array())
  {
    if (empty($array) || !is_array($array)) {
      return $default;
    }

    $out = false;
    foreach ($array as $key => $val) {
      if (!is_null(static::Value($val, $filter, null))) {
        $out[$key] = $val;
      }
    }

    return $out ?: $default;
  }