Create new rule by name

@param  string $ruleName
@param  array  $arguments

@return RuleInterface
@throws Exception\ComponentException
326331
public static function rule($ruleName, $arguments): RuleInterface
    {
        $ruleName = ucfirst($ruleName) . 'Rule';

        foreach (static::$rulesNamespaces as $ruleNamespace) {
            $ruleClass = $ruleNamespace . $ruleName;
            if (class_exists($ruleClass)) {
                return new $ruleClass(...$arguments);
            }
        }

        throw new ComponentException("Class for validator `$ruleName` not found");
    }
987257
public function addFailure($key, $ruleName, array $parameters = [])
    {
        if (!isset($this->failures[$key])) {
            $this->failures[$key] = [];
        }

        $this->failures[$key][$ruleName] = $parameters;

        return $this;
    }
992446
protected function createRule($ruleName, $definition)
    {
        echo "    > create rule $ruleName ...";
        $time = microtime(true);

        if (is_array($definition)) {
            $definition['name'] = $ruleName;
        } else {
            $definition = [
                'class' => $definition,
                'name' => $ruleName,
            ];
        }

        /** @var Rule $rule */
        $rule = \Yii::createObject($definition);

        $this->authManager->add($rule);
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";

        return $rule;
    }
1292592
public function createOrFail(array $arguments)
    {
        $status = $this->create($arguments);

        if (is_wp_error($status)) {
            throw new QueryException('Could not create new comment.');
        }

        return $status;
    }
449748
public function create(array $arguments)
    {
        $post = $this->mockAdapterPost($arguments);

        return wp_insert_post(array_merge(
            (array) $post->getAdaptee(),
            ['post_type' => $this->getSlug()]
        ));
    }
420031
protected function executeCommand($name, array $arguments)
    {
        $command = $this->client->createCommand($name, $arguments);

        return $this->client->executeCommand($command);
    }
735016
public static function createObject( $className, $arguments = array() )
	{
		if( !class_exists( $className ) )
			throw new RuntimeException( 'Class "'.$className.'" has not been loaded' );
		$class	= new ReflectionClass( $className );
		if( $arguments )
			$object	= $class->newInstanceArgs( $arguments );
		else
			$object	= $class->newInstance();
		return $object;
	}
452801
public function addRuleCallback($name, Callable $callback)
    {
        if (!is_string($name)) {
            throw new \InvalidArgumentException('Rule must be a string');
        }

        $rule = $this->createRuleCallback($name, $callback);
        $this->addRule($rule);
    }
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;
    }
1287490
public function create($containerOrName, array $data = [])
    {
        // Check if parent or name is defined
        if (!(
            $containerOrName instanceof Model\ContainerInterface ||
            (is_string($containerOrName) && 0 < strlen($containerOrName))
        )
        ) {
            throw new InvalidOperationException("Excepted instance of ContainerInterface or string.");
        }

        // New instance
        $row = $this->editor->getRepository()->createRow();

        // Create default block
        $this->editor->getBlockManager()->create($row);

        // Add to row if available
        if ($containerOrName instanceof Model\ContainerInterface) {
            $count = $containerOrName->getRows()->count();
            $row->setPosition($count);
            $containerOrName->addRow($row);
        } else {
            $row->setName($containerOrName);
        }

        return $row;
    }
677014
public static function create($name, callable $callback, ...$arguments) {

        try {

            return  new RpcMethod($name, $callback, ...$arguments);

        } catch (Exception $e) {

            throw $e;

        }

    }
598547
public function addRule(Rule $rule)
    {
        $classname = $rule->getClass();
        if ($this->hasRule($classname) === true) {
            throw new Exception(
                "failed to add rule; the field {$this->name} already has an ".
                "instance of '$classname'"
            );
        }
        else if ($classname === Rule::REQUIRED) {
            $this->rules = [$classname => $rule] + $this->rules;
        }
        else {
            $this->rules[$classname] = $rule;
        }
        return $this;
    }
167948
private static function createObject($className, array $args = null)
    {
        try {
            if (!$args) {
                return new $className;
            } else {
                $c = new \ReflectionClass($className);
                return $c->newInstanceArgs($args);
            }
        } catch (\Exception $e) {
            throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
        }
    }
634280
public function create($name, $params = [ ])
    {
        if ($name !== null) {
            $name = $this->getName($name);
        } else {
            $name = $this->_base;
        }

        if (!isset($params['rule'])) {
            $params['rule'] = $this->_rule;
        }

        if (!isset($params['class'])) {
            $params['class'] = $this->_class;
        }

        return $this->link($name, $params);
    }
133043
public static function getRule($ruleName) {

		if (isset(self::$rules[$ruleName])) {
			return self::$rules[$ruleName];
		}

		return false;

	}
128964
public function setRule($fieldName, Rule $rule)
    {
        $this->rules[$fieldName][get_class($rule)] = $rule;
        
        $rule->setValidator($this);
        
        return $this;
    }
629077
public function createNamed(
        $name = null,
        CollectionInterface $filterCollection,
        array $rootFormBuilderOptions = [],
        array $filterFormBuilderOptions = []
    ) {
        return $this->createForm($filterCollection, $name, $rootFormBuilderOptions, $filterFormBuilderOptions);
    }