{@inheritDoc}

@see \Mcustiel\SimpleRequest\Filter\StringReplace::filter()
546290
public function filter($value)
    {
        if (!is_string($value) && !is_array($value)) {
            return $value;
        }
        $result = @preg_replace($this->search, $this->replacement, $value);
        if ($result === null) {
            throw new FilterErrorException('An error occurred executing RegexReplace filter');
        }

        return $result;
    }
439140
public function filter($value)
    {
        $dashToCamelCaseFilter       = new DashToCamelCase();
        $underscoreToCamelCaseFilter = new UnderscoreToCamelCase();

        $value = $dashToCamelCaseFilter->filter($value);
        $value = $underscoreToCamelCaseFilter->filter($value);

        return $value;
    }
702797
public function filter($value)
    {
        if (!is_scalar($value) && !is_array($value)) {
            return $value;
        }

        $value          = parent::filter($value);
        $lowerCaseFirst = 'lcfirst';

        if (StringUtils::hasPcreUnicodeSupport() && extension_loaded('mbstring')) {
            $lowerCaseFirst = function ($value) {
                if (0 === mb_strlen($value)) {
                    return $value;
                }

                return mb_strtolower(mb_substr($value, 0, 1)) . mb_substr($value, 1);
            };
        }

        return is_array($value) ? array_map($lowerCaseFirst, $value) : call_user_func($lowerCaseFirst, $value);
    }
1035678
protected function filterQuery($query)
    {
        $queryStr    = $this->filterString($query);
        $queryDecode = rawurldecode($queryStr);

        return $this->rawurldecodeValue(ltrim($queryDecode, '?'));
    }
122236
public function createFilter($search, $replace)
    {
        if (!isset($this->filters[$search][$replace])) {
            if (!isset($this->filters[$search])) {
                $this->filters[$search] = [];
            }

            if (!isset($this->filters[$search][$replace])) {
                $this->filters[$search][$replace] = [];
            }

            $this->filters[$search][$replace] = new Swift_StreamFilters_StringReplacementFilter($search, $replace);
        }

        return $this->filters[$search][$replace];
    }
1103095
protected function filterRegex($var, $filter)
	{
		if (is_array($var))
		{
			foreach($var as $key => $value)
			{
				$var[$key] = preg_replace('#['.$filter.']#ui', '', $value);
			}
		}
		else
		{
			$var = preg_replace('#['.$filter.']#ui', '', $var);
		}

		return $var;
	}
1319767
public function filter($value)
    {
        if ($this->encodingFormat !== null) {
            $firstChar = mb_substr($value, 0, 1, $this->encodingFormat);
            $rest = mb_substr($value, 1, null, $this->encodingFormat);
            return mb_strtoupper($firstChar, $this->encodingFormat) . $rest;
        }

        $firstChar = mb_substr($value, 0, 1);
        $rest = mb_substr($value, 1);

        return mb_strtoupper($firstChar) . $rest;
    }
1287374
public function find($re, $filter = null) {
        if ($this->isEmpty()) {
            return self::getEmptyContext();
        }

        $result = null;

        if ($filter) {
            $this->findAll($re)->each(function($context) use ($filter, &$result) {
                if ($filter($context)) {
                    $result = $context;
                    return false;
                }
            });

            return $result?:self::getEmptyContext();
        }

        if (!preg_match($re, $this->toString(), $match)) {
            return self::getEmptyContext();
        }

        return new self($match);
    }
449877
function filter( arr, str ) {
	var len = arr.length,
		out = [],
		i;

	for ( i = 0; i < len; i++ ) {
		if ( arr[ i ] !== str ) {
			out.push( arr[ i ] );
		}
	}
	return out;
}
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);
        }
    }
500848
protected static function filterQuery($query)
    {
        if (! is_string($query)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid query provided; must be a string argument',
                (is_object($query) ? get_class($query) : gettype($query))
            ));
        }

        return static::filterQueryOrFragment(ltrim($query, '?'));
    }
1019853
function filter (arrayToFilter, options) {
  // conditions
  const nameFilter = (senador, nombre) => {
    assert(typeof nombre === 'string' || nombre instanceof RegExp, 'El nombre solo se puede filtrar por string o expresion regular')

    return typeof nombre === 'string' ? wrapString(senador.nombre).indexOf(wrapString(nombre)) > -1 : nombre.test(senador.nombre)
  }
  const rutFilter = (senador, rut) => {
    assert(validate(rut), 'el rut de busqueda ingresado no es valido')

    return wrapString(senador.rut) === wrapString(rut)
  }
  const defualtRutFilter = (senador, rut) => {
    rut = rut.toString()

    return senador.rut.split('-')[0] === rut
  }
  const regionFilter = (senador, region) => {
    assert(typeof region === 'string' || region instanceof RegExp, 'La region solo se puede filtrar por string o expresion regular')

    return typeof region === 'string' ? wrapString(senador.region).indexOf(wrapString(region)) > -1 : region.test(senador.region)
  }
  const circunscripcionFilter = (senador, circunscripcion) => {
    assert.equal(typeof circunscripcion, 'number', 'La circunscripción ingresada para buscar debe ser un número')

    return senador.circunscripcion === circunscripcion
  }
  const telefonoFilter = (senador, telefono) => {
    assert(typeof telefono === 'string' || telefono instanceof RegExp, 'El telefono solo se puede filtrar por string o expresion regular')

    return typeof telefono === 'string' ? wrapString(senador.telefono).indexOf(wrapString(telefono)) > -1 : telefono.test(senador.telefono)
  }
  const mailFilter = (senador, mail) => {
    assert(typeof mail === 'string' || mail instanceof RegExp, 'El telefono solo se puede filtrar por string o expresion regular')

    return typeof mail === 'string' ? wrapString(senador.mail).indexOf(wrapString(mail)) > -1 : mail.test(senador.mail)
  }
  const partidoFilter = (senador, partido) => {
    assert(typeof partido === 'string' || partido instanceof RegExp, 'El telefono solo se puede filtrar por string o expresion regular')

    return typeof partido === 'string' ? wrapString(senador.partido).indexOf(wrapString(partido)) > -1 : partido.test(senador.partido)
  }

  const _filter = elem => {
    if (elem.hasOwnProperty('senador')) elem = elem.senador
    // default queries
    if (typeof options === 'string' && elem) return nameFilter(elem, options)
    if (typeof options === 'number' && elem) return defualtRutFilter(elem, options)

    return (options.nombre ? nameFilter(elem, options.nombre) : true) &&
           (options.rut ? rutFilter(elem, options.rut) : true) &&
           (options.region ? regionFilter(elem, options.region) : true) &&
           (options.circunscripcion ? circunscripcionFilter(elem, options.circunscripcion) : true) &&
           (options.telefono ? telefonoFilter(elem, options.telefono) : true) &&
           (options.mail ? mailFilter(elem, options.mail) : true) &&
           (options.partido ? partidoFilter(elem, options.partido) : true)
  }
  return arrayToFilter.filter(_filter)
}
1058131
public function filter($filter)
    {
        preg_match_all("/(#\w+)/", $filter, $entityNames);
        preg_match_all("/(:\w+)/", $filter, $positions);

        $entityName = is_array($entityNames[0]) && isset($entityNames[0][0]) ? ltrim($entityNames[0][0], '#') : null;
        $position   = is_array($positions[0]) && isset($positions[0][0]) ? $positions[0][0] : null;

        $i = 0;

        $filtered = [];

        foreach ($this->entities as $name => $entity) {
            if ($i === 0 && ($entityName === $name || $entityName === null) && ($position === ':first' || $position === ':highest' || $position === null)) {
                $filtered[] = $entity;
            }

            if ($position === ':any' && ($entityName === $name || $entityName === null)) {
                $filtered[] = $entity;
            }

            if ($i + 1 === $this->entities->count() && ($entityName === $name || $entityName === null) && ($position === ':last' || $position === ':lowest')) {
                $filtered[] = $entity;
            }

            $i++;
        }

        $this->filtered = $filtered;

        return $this;
    }
981979
protected static function filterQueryOrFragment($value)
    {
        return preg_replace_callback(
            '/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/u',
            function (array $matches) {
                rawurlencode($matches[0]);
            },
            $value
        );
    }
638136
public function filter($value, $options = [])
    {
        $value = (string) $value;
        if ($this->getEncoding()) {
            return mb_strtoupper($value, $this->getEncoding());
        }

        return strtoupper($value);
    }
807390
public function filter($value)
    {
        if (!is_scalar($value) && !is_array($value)) {
            return $value;
        }

        if ($this->searchSeparator === null) {
            throw new Exception\RuntimeException('You must provide a search separator for this filter to work.');
        }

        $pattern = '#' . preg_quote($this->searchSeparator, '#') . '#';
        return preg_replace($pattern, $this->replacementSeparator, $value);
    }
878266
public function searchAndReplace($str)
	{
		$this->matcher->load($str, $this->collection);

		return $this->matcher->searchAndReplace();
	}