Create Item from a Rule

Current position is placed in the start of rule body.
@param Rule $rule Source rule
@return static Returns new Item
771270
public static function createFromRule(Rule $rule): self
    {
        return new static(
            $rule->getSubject(),
            [],
            $rule->getDefinition(),
            $rule->hasEofMark(),
            $rule->getTag()
        );
    }
993721
public static function basedOn($condition): self
    {
        $name = $condition instanceof Condition ? $condition->name() : $condition;

        return new self($name, '');
    }
1072673
public function update($rule)
    {
        $ruleId = "";

        if (is_array($rule)) {
            $ruleId = $rule["id"];
            unset($rule["id"]);
        }
        elseif (is_object($rule)) {
            $ruleId = $rule->id;
            unset($rule->id);
        }

        return $this->client->put("/validation-rules/" . rawurlencode($ruleId), $rule);
    }
1359412
public function createStory(string $name, RuleInterface ...$rules): Story
    {
        $story = new Story($name, ...$rules);
        $this->addStories($story);

        return $story;
    }
142742
public function add(\Caridea\Validate\Rule ...$rules): self
    {
        $this->rules = array_merge($this->rules, $rules);
        return $this;
    }
165713
protected function _getRule($rule)
    {
        if ($rule instanceof FilterInterface) {
            return $rule;
        }

        $rule = (string) $rule;
        return $this->getPluginManager()->get($rule);
    }
219405
public function rule($name, $rule='')
    {
        if (is_array($name)) {
            $this->rule=array_merge($this->rule, $name);
        } else {
            $this->rule[$name]=$rule;
        }
        return $this;
    }
68492
public function extend(string $rule, string $ruleClass): Validator
	{
		$this->rules[$rule] = $ruleClass;

		return $this;
	}
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;
    }
14343
public function add_rule( $name, $rules ) {
		$parsed = ( new Validation_Parser() )->parse( $rules );

		foreach ( $parsed as $rule ) {
			$this->rule( $rule[0], $name, ...$rule[1] );
		}

		return $this;
	}
1267674
public function addRules(Rule ...$rules): MutableQuery
    {
        $cloned = clone $this;

        $activeRules = iterator_to_array($this->rules);
        $activeRules = array_merge($activeRules, $rules);

        $cloned->rules = new RuleCollection($this->rules->getJoinKeyword(), ...$activeRules);

        return $cloned;
    }
913075
public static function validator(RuleInterface $rule, ContainerInterface $container = null): ValidatorInterface
    {
        $validator = new static($rule, $container);

        return $validator;
    }
763147
public static function create($condition): self
    {
        $condition = $condition instanceof Condition ? $condition : Condition::fromValue($condition);

        return new self($condition);
    }
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;
    }
1082439
static function addRule(\CharlotteDunois\Validation\RuleInterface $rule) {
        if(static::$rulesets === null) {
            static::initRules();
        }
        
        $class = \get_class($rule);
        $arrname = \explode('\\', $class);
        $name = \array_pop($arrname);
        
        $rname = \str_replace('rule', '', \strtolower($name));
        static::$rulesets[$rname] = $rule;
        
        if(\stripos($name, 'rule') !== false) {
            static::$typeRules[] = $rname;
        }
    }
965804
public static function create($rule, \SplPriorityQueue $namespaces = null)
    {
        if (!$rule) {
            return new NoneValidator();
        }

        if (class_exists($rule)) {
            return new $rule();
        }

        $namespaces = $namespaces ?: static::getNamespaces();

        foreach ($namespaces as $namespace) {
            $class = $namespace . '\\' . ucfirst($rule) . 'Validator';

            if (class_exists($class)) {
                return new $class();
            }
        }

        if (is_string($rule)) {
            return new RegexValidator($rule);
        }

        throw new \InvalidArgumentException(sprintf('Validator %s is not exists.', $rule));
    }
441012
public function merge(Set $rules): self
    {
        $this->rules = array_merge($this->rules, $rules->rules);
        return $this;
    }