protected function createRule(string $className, array $args = [])
    {
        if (!class_exists($className)) {
            throw new InvalidArgumentException("Class \"$className\" does not exist");
        }

        /** @var IRule|IRuleWithArgs $rule */
        $rule = new $className;

        if ($rule instanceof IRuleWithArgs) {
            $rule->setArgs($args);
        }

        $this->addRule($rule);
    }
protected function createRule(string $className, array $args = [])
    {
        if (!class_exists($className)) {
            throw new InvalidArgumentException("Class \"$className\" does not exist");
        }

        /** @var IRule|IRuleWithArgs $rule */
        $rule = new $className;

        if ($rule instanceof IRuleWithArgs) {
            $rule->setArgs($args);
        }

        $this->addRule($rule);
    }
protected function createRule ( string $ className , array $ args = [ ] ) { if ( ! class_exists ( $ className ) ) { throw new InvalidArgumentException ( "Class \"$className\" does not exist" ) ; } /** @var IRule|IRuleWithArgs $rule */ $ rule = new $ className ; if ( $ rule instanceof IRuleWithArgs ) { $ rule -> setArgs ( $ args ) ; } $ this -> addRule ( $ rule ) ; }
Adds a rule with the input name and arguments

@param string $className The fully name of the rule class, eg "Opulence\...\RequiredRule"
@param array $args The extra arguments
@throws InvalidArgumentException Thrown if no rule exists with the input name
Adds a rule with the input name and arguments