Recursively apply a filter function

@param     string   $filter    filter to apply
@param     mixed    $value     submitted values
@since     2.0
@access    private
@return    cleaned values
175582
function _recursiveFilter($filter, $value)
    {
        if (is_array($value)) {
            $cleanValues = array();
            foreach ($value as $k => $v) {
                $cleanValues[$k] = $this->_recursiveFilter($filter, $v);
            }
            return $cleanValues;
        } else {
            return call_user_func($filter, $value);
        }
    }
1010060
private function all_filters( $values ) {

		foreach ( $values as $key => $value ) {
			foreach ( $this->filters as $filter ) {
				$values[ $key ] = $filter->filter( $value );
			}
		}

		return $values;
	}
137706
public function filter($value)
    {
        // perform some transformation upon $value to arrive on $valueFiltered
        $valueFiltered = strtoupper(trim($value));
        if (strlen($valueFiltered) == 6) {
            if (preg_match('/\d{4,4}[A-Z]{2,2}/', $valueFiltered)) {
                $valueFiltered = substr_replace($valueFiltered, ' ', 4, 0);
            }
        }

        return $valueFiltered;
    }
347215
public function filter($value)
    {
        $params = (array) $this->options['callback_params'];
        array_unshift($params, $value);

        return call_user_func_array($this->options['callback'], $params);
    }
1348116
public function applyFilters($hook, $value)
    {
        $hook = (string) $hook;
        if (empty($this->hooks[$hook])) {
            return $value; // No hooks.
        }
        $hook_filters = $this->hooks[$hook];
        $args         = func_get_args();
        ksort($hook_filters);

        foreach ($hook_filters as $_hook_filter) {
            foreach ($_hook_filter as $_filter) {
                if (!isset($_filter['function'], $_filter['accepted_args'])) {
                    continue; // Not a valid filter in this case.
                }
                $args[1] = $value; // Continously update the argument `$value`.
                $value   = call_user_func_array($_filter['function'], array_slice($args, 1, $_filter['accepted_args']));
            }
        }
        unset($_hook_filter, $_filter); // Housekeeping.

        return $value; // With applied filters.
    }
435144
public function set_filter_values($filter, array $values = []) {
        $allvalues = (array) $this->get_config('filtervalues', []);
        $allvalues[$filter] = $values;

        return $this->set_config('filtervalues', $allvalues);
    }
1198751
public function filter($value)
    {
        $lowerFilter = new \Zend_Filter_StringToLower();
        $value = $lowerFilter->filter(parent::filter($value));
        preg_match_all(self::SLUG_PATTERN, $value, $return);
        
        return implode($this->getWordSeparator(), $return[0]);
    }
451049
public function filter($value) {

        $testvalue = $this->options["insensitive"] ? strtolower($value): $value;

        // Value is not in enumeration
        if (!in_array($testvalue, $this->enumeration, $this->options["strict"]))
            return Filter::ERR_INVALID;

        $found = array_search($value, $this->enumeration, $this->options["strict"]);

        return $this->options["values"][$found];
    }
1012283
public function filter($filter = null)
    {
        if (is_null($filter)) {
            return $this->filter;
        } else {
            $this->filter = $filter;
        }
    }
444613
public function applyFilter($filter, $args = null)
    {
        $args = func_get_args();
        $args[0] = $this;
        return call_user_func_array(
            $filter instanceof Closure ? $filter : $this->getConnection()->getFilterCallback($filter),
            $args
        );
    }
979050
public function filter($value)
    {
        $replace = $this->getReplaceCallback();
        $filtered = $value;

        foreach ($this->patterns as $index => $pattern)
        {
            $filtered = preg_replace_callback($pattern, $replace[$index], $filtered);
        }

        return $filtered;
    }
28057
private function filter(string $value) : string
    {
        foreach ($this->filters as $filter) {
            $value = $filter($value);
        }

        return $value;
    }
1251325
public function filter($value)
    {
        if (!is_string($value)) {
            return $value;
        }
        return $this->allWords ? ucwords(strtolower($value)) : ucfirst(strtolower($value));
    }
701890
private function applyInputFilters($value, $filters)
    {
        foreach ($filters as $filter) {
            if (is_string($filter) && isset(self::$filterCallbacks[$filter])) {
                $value = call_user_func(self::$filterCallbacks[$filter], $value);
            }
        }
        return $value;
    }
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;
    }
1143163
public function applyFilters($value, $rules = array())
    {
        $valueTO = $this->valueTO->forge($value);
        // loop through all the rules to validate $value.
        foreach ($rules as $rule => $parameter) {
            // skip rules with option as FALSE.
            if ($parameter === false) {
                continue;
            }
            $this->filter->apply($rule, $valueTO, $parameter);

            // loop break.
            if ($valueTO->getBreak()) {
                break;
            }
        }

        return $valueTO;
    }
1327060
public function set($key, $value = null, $filter = null)
	{
		parent::set($key, $value);

		if (is_array($key))
		{
			if (is_bool($value))
			{
				$filter = $value;
			}

			foreach ($key as $_key => $_value)
			{
				$this->filterIndex[$_key] = $filter;
			}
		}
		else
		{
			$this->filterIndex[$key] = $filter;
		}

		return $this;
	}