add a rule

@param xml\MergeRuleInterface $rule
@param string $name
516033
public function add(MergeRuleInterface $rule, $name = null)
	{
	    if (!empty($name)) {
	    	$this->_items[$name] = $rule;
	    } else {
	    	$this->_items[] = $rule;
	    }

	    return $this;
	}
1315979
public function addRule(Rule $rule)
    {
        $this->addReason($rule->getId(), array(
            'rule' => $rule,
            'job' => $rule->getJob(),
        ));
    }
431342
public function pattern($name, $rule = '')
    {
        if (is_array($name)) {
            $this->pattern = array_merge($this->pattern, $name);
        } else {
            $this->pattern[$name] = $rule;
        }

        return $this;
    }
663209
public function addRule($rule)
    {
        if (count($this->rules) >= self::OSS_MAX_RULES) {
            throw new OssException("num of rules in the config exceeds self::OSS_MAX_RULES: " . strval(self::OSS_MAX_RULES));
        }
        $this->rules[] = $rule;
    }
844816
protected function addMatched(string $name)
    {
        if (! isset($this->matched[$name])) {
            $this->matched[$name] = $this->newMiddleware($name);
        }
    }
785496
public function addRule($configuration, RuleInterface $rule)
    {
        if ($this->getConfiguredRule($configuration, $rule) === '') {
            $configuration = rtrim($configuration);
            if ($configuration !== '') {
                $configuration .= "\n\n";
            }
            $commentsBefore = $rule->getCommentsBefore();
            if ($commentsBefore !== '') {
                $configuration .= $commentsBefore."\n";
            }
            $configuration .= $rule->getCode()."\n";
            $commentsAfter = $rule->getCommentsAfter();
            if ($commentsAfter !== '') {
                $configuration .= $commentsAfter."\n";
            }
        }

        return $configuration;
    }
1069949
public function addImplicitExtension($rule, $extension)
    {
        $this->addExtension($rule, $extension);

        $this->implicitRules[] = Str::studly($rule);
    }
159603
public function addQuery($name, $value)
    {
        $this->query = array_merge_recursive($this->query, [$name => $value]);
    }
1126575
protected function addGroupName(XType $type, &$rule)
    {
        $groupName = $this->groupName($type);

        if (isset($this->typeToRule[$groupName])) {
            $rule[] = $this->typeToRule[$groupName];
        }
    }
437576
public function add(FilterRule $rule)
    {
        $this->rules[$rule->getName()] = $rule;

        if (!\is_null($rule->getValue())) {
            $this->hasDefaults = true;
        }

        return $this;
    }
582732
public function add($name, $pattern)
	{
		if(isset($this->data[$name]))
			throw new \Exedra\Exception\Exception('Registry by name ['.$name.'] already exist.');
			
		$this->data[$name] = $pattern;
	}
646579
public function addQueryRules(
        string $name,
        ?RuleInterface $identityRule,
        ?array $filterRules,
        ?array $fieldSetRules,
        ?RuleInterface $sortsRule,
        ?RuleInterface $includesRule,
        ?RuleInterface $pageOffsetRule,
        ?RuleInterface $pageLimitRule
    ): JsonApiQueryRulesSerializerInterface {
        assert(!empty($name));
        assert(static::hasRules($name, $this->serializedRules) === false);

        $identityRule === null ?: $identityRule->setName(JsonApiQueryParserInterface::PARAM_IDENTITY);
        $sortsRule === null ?: $sortsRule->setName(JsonApiQueryParserInterface::PARAM_SORT);
        $includesRule === null ?: $includesRule->setName(JsonApiQueryParserInterface::PARAM_INCLUDE);
        $pageOffsetRule === null ?: $pageOffsetRule->setName(JsonApiQueryParserInterface::PARAM_PAGE);
        $pageLimitRule === null ?: $pageLimitRule->setName(JsonApiQueryParserInterface::PARAM_PAGE);

        $this->serializedRules[$name] = [
            static::IDENTITY_RULE     =>
                $identityRule === null ? null : $this->addRules([static::SINGLE_RULE_INDEX => $identityRule]),
            static::FILTER_RULES     =>
                $filterRules === null ? null : $this->addRules($filterRules),
            static::FIELD_SET_RULES  =>
                $fieldSetRules === null ? null : $this->addRules($fieldSetRules),
            static::SORTS_RULE       =>
                $sortsRule === null ? null : $this->addRules([static::SINGLE_RULE_INDEX => $sortsRule]),
            static::INCLUDES_RULE    =>
                $includesRule === null ? null : $this->addRules([static::SINGLE_RULE_INDEX => $includesRule]),
            static::PAGE_OFFSET_RULE =>
                $pageOffsetRule === null ? null : $this->addRules([static::SINGLE_RULE_INDEX => $pageOffsetRule]),
            static::PAGE_LIMIT_RULE  =>
                $pageLimitRule === null ? null : $this->addRules([static::SINGLE_RULE_INDEX => $pageLimitRule]),
        ];

        return $this;
    }
1181052
protected static function required(RuleInterface $rule = null): RuleInterface
    {
        return $rule === null ? new Required(static::success()) : new Required($rule);
    }
177879
public function addDependentExtension($rule, $extension)
    {
        $this->addExtension($rule, $extension);

        $this->dependentRules[] = Str::studly($rule);
    }
1194180
protected function addComponent(IComponent $component, $name, $insertBefore = NULL)
	{
		if ($this->childControl) {
			throw new LogicException('child control for this cell has already been set, you cannot add another one');
		}

		/** @noinspection PhpInternalEntityUsedInspection */
		$this->row->addComponent($component, $name, $insertBefore);
		$this->childControl = $component;
	}
96051
public function mergeRules(array $rules)
    {
        $this->extendedRules = array_merge($this->extendedRules, $rules);
        $this->parsedRules = null;
        return $this;
    }
755224
public function addRule(RuleAbstract $rule)
    {
        // TODO Keyframes with duplicate identifiers do NOT cascade!
        // Last one overwrites previous ones.
        // @see https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes#Duplicate_resolution

        if ($rule instanceof KeyframesRuleSet) {
            $this->rules[] = $rule;
        } else {
            throw new \InvalidArgumentException(
                "Invalid rule instance. Instance of 'KeyframesRuleSet' expected."
            );
        }

        return $this;
    }