Getter/Setter for the filter rules.

@param array $rules

@return array
764031
public function filterRules(array $rules = array())
    {
        if (empty($rules)) {
            return $this->filterRules;
        }

        $this->filterRules = $rules;

        return $this;
    }
918082
private function sortRules(&$rules)
    {
        sort($rules);
        usort($rules, function ($a, $b) {
            return strlen($a) - strlen($b);
        });
    }
205433
public static function getRulesIndexes(array $arrayRulesIndexes): array
    {
        assert(array_key_exists(static::RULES_ARRAY_INDEXES, $arrayRulesIndexes));
        $result = $arrayRulesIndexes[static::RULES_ARRAY_INDEXES];

        return $result;
    }
398352
protected function explodeRules($rules)
    {
        foreach ($rules as $key => $rule) {
            if (Str::contains($key, '*')) {
                $rules = $this->explodeWildcardRules($rules, $key, [$rule]);

                unset($rules[$key]);
            } else {
                $rules[$key] = $this->explodeExplicitRule($rule);
            }
        }

        return $rules;
    }
354946
public function sanitize(array $data, array $rules = [], array $filters = [])
    {
        $this->setRules($rules);
        $this->setFilters($filters);

        foreach ($data as $name => $value) {
            $data[$name] = $this->sanitizeAttribute($name, $value);
        }

        return $data;
    }
960899
public function rules($rules)
    {
        foreach ($rules as $rule => $field) {
            if (is_array($field) && is_array($field[0])) {
                foreach ($field as $params) {
                    array_unshift($params, $rule);
                    call_user_func_array([$this, 'rule'], $params);
                }
            } else {
                $this->rule($rule, $field);
            }
        }
        return $this;
    }
1338720
protected function explodeRules($rules)
    {
        foreach ($rules as $key => $rule) {
            $rules[$key] = is_string($rule) ? explode('|', $rule) : $rule;
        }

        return $rules;
    }
577769
public function parse($rules)
    {
        $attributes = array();
        $rules = $rule = $this->getRulesAsArray($rules);

        foreach ($rules as $rule) {
            list($rule, $parameters) = $this->parseRule($rule);

            if ($rule && method_exists($this, $rule)) {
                $attributes += $this->$rule($parameters);
            }
        }

        return $attributes;
    }
325970
protected function generateRules($rules)
    {
        return collect($rules)->mapWithKeys(function ($rules, $key) {
            return [$this->attribute . '.' . $key => $rules];
        })->toArray();
    }
1250357
protected function getRulesAsArray($rules) {
        $rulesArray = (is_string($rules)) ? explode('|', $rules) : $rules;

        return array_map(function($rule) {
            if ($rule instanceof \Closure) {
                return $rule($this->field->getNameKey());
            }

            return $rule;
        }, $rulesArray);
    }
916341
public function rewrite_rules_array( array $rules ){
        if( !empty($this->rewrites) ){
            $rules = array_merge($this->rewrites, $rules);
        }
        return $rules;
    }
1205089
public function rules($field, array $rules)
    {
        foreach ($rules as $rule)
        {
            $this->rule($field, $rule[0], Arr::get($rule, 1));
        }

        return $this;
    }
981917
public function setRules(array $rules)
    {
        $this->rules = [];
        foreach ($rules as $key => $value) {
            if (is_int($key)) {
                $routeRegex  = $value;
                $permissions = [];
            } else {
                $routeRegex  = $key;
                $permissions = (array) $value;
            }
            $this->rules[$routeRegex] = $permissions;
        }
    }
13576
private function array_to_css( array $rules )
    {
        $css = '';
        foreach( $rules as $rule => $value )
        {
            $css .= $rule.':'.$value.';';
        }
        return $css;
    }
715799
public function setFilters($filters)
    {
        if ($filters === null)
            $filters = [];
        else if (!is_array($filters))
            throw new \Exception('Filters should be null or array');

        foreach ($filters as $column => $filter) {
            $found = [];
            foreach ($this->getColumns() as $id => $params) {
                if ($id == $column) {
                    foreach ($filter as $name => $value) {
                        if (in_array($name, $params['filters']))
                            $found[$name] = $value;
                    }
                    break;
                }
            }

            if (count($found) > 0)
                $filters[$column] = $found;
            else
                unset($filters[$column]);
        }

        $this->filters = $filters;
        return $this;
    }
658510
private function formatRule($rules)
    {
        if (is_array($rules)) {
            foreach ($rules as $rule) {
                $formatted[] = $this->formatRule($rule);
            }

            return $formatted ?? [];
        }

        if (is_object($rules) || is_callable($rules)) {
            return $rules;
        }

        if (Str::contains($rules, 'required_if') && preg_match('/(.*):(.*),(.*)/', $rules, $matches)) {
            $column = Str::startsWith($matches[2], '*.') ? $matches[2] : '*.' . $matches[2];

            return $matches[1] . ':' . $column . ',' . $matches[3];
        }

        return $rules;
    }
165713
protected function _getRule($rule)
    {
        if ($rule instanceof FilterInterface) {
            return $rule;
        }

        $rule = (string) $rule;
        return $this->getPluginManager()->get($rule);
    }