public function registerRuleExtension($rule, string $slug = '')
    {
        if ($rule instanceof IRule) {
            $slug = $rule->getSlug();
        }

        if (is_callable($rule)) {
            $callback = $rule;
            $rule = new CallbackRule();
            $rule->setArgs([$callback]);
        }

        if (!$rule instanceof IRule) {
            throw new InvalidArgumentException('Rule must either be a callback or implement IRule');
        }

        $this->extensions[$slug] = $rule;
    }
public function registerRuleExtension($rule, string $slug = '')
    {
        if ($rule instanceof IRule) {
            $slug = $rule->getSlug();
        }

        if (is_callable($rule)) {
            $callback = $rule;
            $rule = new CallbackRule();
            $rule->setArgs([$callback]);
        }

        if (!$rule instanceof IRule) {
            throw new InvalidArgumentException('Rule must either be a callback or implement IRule');
        }

        $this->extensions[$slug] = $rule;
    }
public function registerRuleExtension ( $ rule , string $ slug = '' ) { if ( $ rule instanceof IRule ) { $ slug = $ rule -> getSlug ( ) ; } if ( is_callable ( $ rule ) ) { $ callback = $ rule ; $ rule = new CallbackRule ( ) ; $ rule -> setArgs ( [ $ callback ] ) ; } if ( ! $ rule instanceof IRule ) { throw new InvalidArgumentException ( 'Rule must either be a callback or implement IRule' ) ; } $ this -> extensions [ $ slug ] = $ rule ; }
Registers a rule extension

@param IRule|callable $rule Either the rule object or callback (that accepts a value and list of all values) and
returns true if the rule passes, otherwise false
@param string $slug The slug name of the rule (only used if the rule is a callback)
@throws InvalidArgumentException Thrown if the rule was incorrectly formatted
Registers a rule extension