@param iterable $transforms List of rules or rulesets to be used by the Transliterator,
like `Lower`, `ASCII` or `a > b; c > d`

@return static
420973
public function setTransforms(iterable $transforms): self
	{
		$this->transforms = [];

		foreach ($transforms as $transform) {
			$this->assertTransform($transform);
			$this->addTransform($transform, false);
		}

		$this->setOptions['transforms'] = null;

		return $this;
	}
996036
public function setRules(array $rules)
    {
        foreach ($rules as $key => $values) {

            if ((is_array($values) === true && empty($values) === false) || is_callable($values)) {
                $this->rules[$key] = $values;
            } else {
                $this->rules[$key] = trim($values);
            }
        }

        return $this;
    }
535422
private function getValidatedFilters(): iterable
    {
        $ruleIndexes = $this->serializerClass::readFilterRulesIndexes($this->getSerializedRuleSet());

        if ($ruleIndexes === null) {
            // without validation
            foreach ($this->getFilterParameters() as $field => $operationsWithArgs) {
                yield $field => $this->parseOperationsAndArguments(static::PARAM_FILTER, $operationsWithArgs);
            }
        } else {
            // with validation
            $mainIndexes = $this->serializerClass::readRuleMainIndexes($ruleIndexes);
            $this->validationStarts(static::PARAM_FILTER, $ruleIndexes);
            foreach ($this->getFilterParameters() as $field => $operationsWithArgs) {
                if (is_string($field) === false || empty($field) === true ||
                    is_array($operationsWithArgs) === false || empty($operationsWithArgs) === true
                ) {
                    throw new InvalidQueryParametersException($this->createParameterError(
                        static::PARAM_FILTER,
                        $this->getInvalidParamMessage()
                    ));
                }

                if (array_key_exists($field, $mainIndexes) === false) {
                    // unknown field set type
                    $this->getValidationErrors()->add(
                        new ValidationError(
                            static::PARAM_FILTER,
                            $field,
                            ErrorCodes::INVALID_VALUE,
                            Messages::INVALID_VALUE,
                            []
                        )
                    );
                } else {
                    // for field a validation rule is defined so input value will be validated
                    $ruleIndex = $mainIndexes[$field];
                    $parsed    = $this->parseOperationsAndArguments(static::PARAM_FILTER, $operationsWithArgs);

                    yield $field => $this->validateFilterArguments($ruleIndex, $parsed);
                }
            }
            $this->validateEnds(static::PARAM_FILTER, $ruleIndexes);
        }
    }
686997
public function filter($value)
    {
        $transliteration = new Transliteration();

        $value = $transliteration->filter($value);
        $value = mb_strtolower($value);

        $value = strtr($value, $this->replaces);

        $value = trim($value, '_-');

        $value = preg_replace('|[^A-Za-z0-9.(){}_-]|isu', '_', $value);

        do {
            $oldLength = strlen($value);
            $value = str_replace('__', '_', $value);
        } while ($oldLength != strlen($value));

        if (strlen($value) == 0) {
            $value = '_';
        }

        $map = [
            '..' => '__',
            '.' => '_',
        ];

        if (isset($map[$value])) {
            $value = $map[$value];
        }

        return $value;
    }
702387
public static function decode($rules = null)
	{
		$parser = new static;

		if (is_string($rules) && trim($rules) !== '') {
			$parser->rules = Collection::make(explode('|', $rules));
		} else {
			$parser->rules = new Collection;
		}

		return $parser;
	}
1250023
public function whereKeysLike($patterns)
    {
        if (! $patterns instanceof Collection) {
            $patterns = new Collection((array) $patterns);
        }

        /* @var Collection $patterns */

        if ($patterns->filter()->isEmpty()) {
            return new static($this->all());
        }

        /**
         * Return a subset of pairs that match any of the given patterns.
         */
        return $this->pairs()->filter(function (LineInterface $line) use ($patterns) {
            return $patterns->contains(function ($index, $pattern) use ($line) {
                return fnmatch($pattern, $line->key());
            });
        });
    }
1373129
public function withTemplates(array $templates): Validator
    {
        $translator = $this->translator->withTemplates($templates);

        return new Validator($this->rules, $this->parser, $translator);
    }
683128
protected function createTransformation(array $transformations)
    {
        return new Transformation(
            isset($transformations['query']) ? $transformations['query'] : '',
            $transformations['writer'],
            isset($transformations['source']) ? $transformations['source'] : '',
            isset($transformations['artifact']) ? $transformations['artifact'] : ''
        );
    }
513981
public function addRules(array $rules)
    {
        foreach ($rules as $character => $replacement) {
            $this->addRule($character, $replacement);
        }

        return $this;
    }
1111454
public function filter($value)
        {
            // transliteration
            $value = strtr($value, $this->transliteration);

            // change to lowercase
            if($this->transformCase) {
                $value = mb_convert_case($value, MB_CASE_LOWER, 'utf8');
            }

            // replace punctuation
            if($this->transformPunctuation) {
                $value = strtr($value, $this->punctuation);
            }

            return $value;
        }
1348757
private function setRuleIndexes(array $ruleIndexes): self
    {
        assert($this->debugCheckIndexesExist($ruleIndexes));

        $this->ruleIndexes     = $ruleIndexes;
        $this->ruleMainIndexes = $this->getSerializer()::readRuleMainIndexes($ruleIndexes);

        return $this;
    }
1080799
public function setPunctuationReplacements($replacements)
        {
            if(!is_array($replacements)) {
                throw new \Thin\Exception(__METHOD__ . ': method expects a keyed array as argument.', 500);
            }
            foreach($replacements as $key => $value) {
                $this->punctuation[$key] = $value;
            }
            return $this;
        }
1368639
public function & rules(array $rules){
      foreach ((array)$rules as $varname => $rule){
        $this->rules[$varname] = $rule;
      }
      $this->pattern         = $this->compilePatternAsRegex( $this->URLPattern, $this->rules );
      $this->matcher_pattern = $this->compilePatternAsRegex( $this->URLPattern, $this->rules, false );
      return $this;
    }
218800
protected function pipe(callable $transformation) : FormatterAbstract
    {
        $that = clone $this; // Immutability!
        array_push($that->transformations, $transformation);

        return $that;
    }
647425
public static function in($values)
    {
        if ($values instanceof Arrayable) {
            $values = $values->toArray();
        }

        return new Rules\In(is_array($values) ? $values : func_get_args());
    }
776327
public function setFormats($formats)
    {
        foreach ($formats as $type => $format) {
            $this->setFormat($type, $format);
        }

        return $this;
    }
576006
public function replace(iterable $values): self
    {
        $this->items = $this->combine($values, true)->toArray();

        return $this;
    }