Resolve named filters and convert them to filter objects.

@param  string $rule
@return FilterInterface
165713
protected function _getRule($rule)
    {
        if ($rule instanceof FilterInterface) {
            return $rule;
        }

        $rule = (string) $rule;
        return $this->getPluginManager()->get($rule);
    }
1078731
protected function addRule(FilterRule $rule)
    {
        if ($this->keys === null) {
            $this->filter->addFilterRule($rule);
        }

        if (is_array($this->keys)) {
            foreach ($this->keys as $key) {
                $this->filter->addFilterRule($rule, $key);
            }
        } else {
            $this->filter->addFilterRule($rule, $this->keys);
        }

        return $this;
    }
851431
public function evaluate(RuleInterface $rule, array $context = [])
    {
        $context = array_merge(
            $this->contextProvider->getContext(),
            $context
        );

        return $this
            ->expressionLanguage
            ->evaluate($rule->getExpression(), $context);
    }
938225
public function regex($rule) {
        $this->check_role = 'regex';
        $this->rule = $rule;
        $result = $this->checkRegex($this->value, $rule);
        $this->checkResult($result);
        return $this;
    }
867610
protected function prepareRule($rule)
    {
        if ($rule instanceof Closure) {
            $rule = new ClosureValidationRule($rule);
        }

        if (! is_object($rule) ||
            $rule instanceof RuleContract ||
            ($rule instanceof Exists && $rule->queryCallbacks()) ||
            ($rule instanceof Unique && $rule->queryCallbacks())) {
            return $rule;
        }

        return (string) $rule;
    }
288324
public function parse($rule)
    {
        if ($this->parser === null) {
            $this->parser = Compiler\Llk::load(
                new File\Read(__DIR__.'/../Grammar.pp')
            );
        }

        $this->nextParameterIndex = 0;

        return $this->visit($this->parser->parse($rule));
    }
1285885
protected static function convertPartialMatchRule($rule)
  {
    /** @var RPartialMatchRule $convertedRule */
    $convertedRule = null;
    if (!empty($rule)) {
      $convertedRule = new RPartialMatchRule();
      $convertedRule->setTerms($rule->getTerms())
          ->setTermsGreaterThan($rule->getTermsGreaterThan())
          ->setMustMatch($rule->getMustMatch())
          ->setPercentage($rule->isPercentage());
    }
    return $convertedRule;
  }
1334442
public function set(string $name, $rule = null): RuleManager
    {
        if (empty($rule)) {
            $rule = $name;
        }

        if (!$this->validateRule($rule)) {
            throw new RuleException("Unable to set rule '{$name}', invalid rule body");
        }

        $this->rules[$name] = $rule;

        return $this;
    }
354520
public function removeObservedCssRule($rule)
    {
        if (isset($this->observedCssRules[$rule])) {
            unset($this->observedCssRules[$rule]);
        }

        return $this;
    }
676856
protected function parseRule(string $rule): object
	{
		$package = null;

		if(preg_match('/^([a-z-]+)::(.*)/', $rule, $matches) === 1)
		{
			$package = $matches[1];
		}

		[$name, $parameters] = $this->parseFunction($rule, false);

		return (object) compact('name', 'parameters', 'package');
	}
366436
public function filter(/*Callable*/ $filter)
    {
        $result = clone $this;
        foreach ($this as $object)
        {
            if (call_user_func($filter, $object) === false) {
                $result->remove($object);
            }
        }

        return $result;
    }
547500
public function filterRules($rules)
    {
        foreach ($this->_behaviors as $name => $foo) {
            if (($behavior = $this->getBehavior($name)) instanceof \nineinchnick\usr\components\FormModelBehavior) {
                $rules = $behavior->filterRules($rules);
            }
        }

        return $rules;
    }
593226
public function onDelete(string $rule = self::NO_ACTION): AbstractForeignKey
    {
        $this->deleteRule = strtoupper($rule);

        return $this;
    }
739166
public function getFilter($name)
    {
        $filter = null;
        if(isset($this->_filters[$name])) {
            $filter = $this->_filters[$name];
        }

        return $filter;
    }
832542
public function withRule(Rule $rule): RulesCollection
    {
        $rules = array_merge($this->rules, [$rule]);

        return new RulesCollection($rules);
    }
363268
protected function callExtension($rule, $parameters)
    {
        $callback = $this->extensions[$rule];

        if ($callback instanceof Closure) {
            return call_user_func_array($callback, $parameters);
        } elseif (is_string($callback)) {
            return $this->callClassBasedExtension($callback, $parameters);
        }
    }
283528
public function rule($name, $rule = '')
    {
        if (is_array($name)) {
            $this->rule = $name + $this->rule;
            if (is_array($rule)) {
                $this->field = array_merge($this->field, $rule);
            }
        } else {
            $this->rule[$name] = $rule;
        }

        return $this;
    }