@param RuleInterface $rule

@return array
425060
public static function encodeRule(RuleInterface $rule): array
    {
        $result = [
            static::TYPE             => static::TYPE_RULE,
            static::RULE_NAME        => $rule->getName(),
            static::RULE_TARGET      => static::encodeTarget($rule->getTarget()),
            static::RULE_CONDITION   => static::serializeMethod($rule->getCondition()),
            static::RULE_EFFECT      => static::serializeMethod($rule->effect()),
            static::RULE_OBLIGATIONS => static::encodeObligations($rule->getObligations()),
            static::RULE_ADVICE      => static::encodeAdvice($rule->getAdvice()),
        ];

        return $result;
    }
1344268
private function checkTokenForOnlyRule(RuleInterface $rule, $token): bool
    {
        $fitRuleRequirements = false;
        foreach ($rule->getRequirements() as $req) {
            if (false !== strpos($token, $req)) {
                $fitRuleRequirements = true;
            }
        }

        return $fitRuleRequirements;
    }
263762
public function reflect(RuleInterface $rule = null)
    {
        $this->setParameterValue($rule->getData());

        return $this->doReflect($rule);
    }
303728
protected function ruleToArray($rule)
    {
        if ($rule instanceof ConstraintGroup || $rule instanceof Constraint) {
            return $this->constraintToArray($rule);
        }

        return $this->parseConstraint($rule);
    }
671036
public function match(RuleInterface $rule, NodeInterface $node): bool
    {
        if (false !== strpos($node->getSubject(), $rule->getSubject())) {
            return true;
        }

        return false;
    }
543214
private function getItems(PropertyInterface $property)
    {
        $value = $this->getValue($property);
        if (!is_array($value['items']) || 0 === count($value['items'])) {
            return [];
        }

        return $value['items'];
    }
458989
public function converterRule($rule) {
        if (!is_array($rule)) {
            $rule = explode('|', $rule);
        }
        $rules = [];
        $message = null;
        foreach ($rule as $key => $item) {
            if (!is_integer($key)) {
                $rules[$key] = $item;
                continue;
            }
            if (is_callable($item)) {
                $rules[] = $item;
            }
            if (!is_string($item) || strpos($item, ':') === false) {
                $rules[$item] = [];
                continue;
            }
            list($key, $val) = explode(':', $item, 2);
            if ($key == 'message') {
                $message = $val;
                continue;
            }
            $rules[$key] = explode(',', $val);
        }
        return compact('rules', 'message');
    }
707959
public function getRules(EventInterface $event) {
        $request = $event->getRequest();
        $publicKey = $request->getRoute()->get('publickey');

        $accessControl = $event->getAccessControl();
        $keyExists = $accessControl->publicKeyExists($publicKey);

        if (!$keyExists) {
            throw new RuntimeException('Public key not found', 404);
        }

        $accessList = $accessControl->getAccessListForPublicKey($publicKey);

        if ($request->query->has('expandGroups')) {
            foreach ($accessList as &$rule) {
                if (!isset($rule['group'])) {
                    continue;
                }

                $rule['resources'] = $accessControl->getGroup($rule['group']);
            }
        }

        $model = new AccessRulesModel();
        $model->setRules($accessList);

        $event->getResponse()->setModel($model);
    }
948893
protected function compileTransposeModulo(array $rule)
    {
        return array(
            'regexp' => '([' .
                preg_quote(
                    $this->getModuloCharRange(
                        $this->compileCharacter($rule['data']['srcStart']),
                        $this->compileCharacter($rule['data']['srcEnd']),
                        $rule['data']['modulo']
                    )
                ) .
                '])us',
            'callback' => $this->getTransposeClosure($rule['data']['op'], $rule['data']['dest']),
        );
    }
165713
protected function _getRule($rule)
    {
        if ($rule instanceof FilterInterface) {
            return $rule;
        }

        $rule = (string) $rule;
        return $this->getPluginManager()->get($rule);
    }
1320055
public function optimize(array $rules): array
    {
        assert(empty($rules) === false);

        $ruleId       = 0;
        $rawTargets   = [];
        $encodedRules = [];
        foreach ($rules as $rule) {
            /** @var RuleInterface $rule */
            $rawTargets[$ruleId]   = $rule->getTarget();
            $encodedRules[$ruleId] = Encoder::encodeRule($rule);
            $ruleId++;
        }

        $callable         = static::METHOD;
        $optimizedTargets = $this->optimizeTargets($rawTargets);

        /** @var callable|array $callable */
        assert($callable !== null && is_array($callable) === true &&
            is_callable($callable) === true && count($callable) === 2 &&
            is_string($callable[0]) === true && is_string($callable[1]) === true);

        return [
            static::INDEX_TARGETS  => $optimizedTargets,
            static::INDEX_RULES    => $encodedRules,
            static::INDEX_CALLABLE => $callable,
        ];
    }
6800
public static function roleId(RuleInterface $next = null): RuleInterface
    {
        return self::asSanitizedString(self::readable(RolesApi::class, $next));
    }
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);
    }
626118
protected function getRuleArgument($rule)
    {
        $exploded = explode(':', $rule);

        return isset($exploded[1]) ?
            array('rule' => $exploded[0], 'argument' => $exploded[1]) : null;
    }
699514
private function parseRule($rule)
	{
		if (!is_array($rule) || (count($rule) < 2)) {
			throw new ValidatorException('Invalid declaration of validation rule');
		}

		is_array($rule[0]) || $rule[0] = [$rule[0]];

		if (!is_string($rule[1])) {
			throw new ValidatorException('Validator name: Expected string');
		}

		if (isset($rule[2])) {
			if(!is_array($rule[2])) {
				throw new ValidatorException('Validator options: Expected array');
			}
		} else {
			$rule[2] = [];
		}
		$rule[2] = new ArrayWrapper($rule[2]);

		return $rule;
	}
687893
public function getFilterForRule(Rule $rule)
    {
        $filterIdentifier = $rule->getFilter();

        if ($this->container === null || !$this->container->has($filterIdentifier)) {
            return parent::getFilterForRule($rule);
        }

        return $this->container->get($filterIdentifier);
    }
182592
public function removeRuleFromItems($rule) {
		$result = $this->repository->removeRuleFromItems($rule);
		$this->domain->const->generateAll();
		return $result;
	}