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");
    }
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");
    }
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" ) ; }
Create new rule by name

@param  string $ruleName
@param  array  $arguments

@return RuleInterface
@throws Exception\ComponentException
Create new rule by name