src/RulesParser.php
private function parseRuleDefinition($key, $definition): Rule
    {
        if (is_string($definition)) {

            $parts = preg_split('/:/', $definition, 2);

            $factory_name = $parts[0];
            $parameters = $parts[1] ?? null;

            $parameters = ! is_null($parameters)
                ? explode(',', $parameters)
                : [];

            $factory_name = trim($factory_name);
            $parameters = array_map('trim', $parameters);

            $factory = $this->getRuleFactory($factory_name);

            $name = is_string($key) ? $key : $factory_name;
            $validate = $factory($parameters);

            return new Rule($name, $validate);

        }

        // is_callable must be AFTER is_string, otherwise factories named like a
        // php function can't be used (ex: date).
        if (is_callable($definition)) {

            return new Rule((string) $key, $definition);

        }

        throw new InvalidRuleFormatException($definition);
    }
private function parseRuleDefinition($key, $definition): Rule
    {
        if (is_string($definition)) {

            $parts = preg_split('/:/', $definition, 2);

            $factory_name = $parts[0];
            $parameters = $parts[1] ?? null;

            $parameters = ! is_null($parameters)
                ? explode(',', $parameters)
                : [];

            $factory_name = trim($factory_name);
            $parameters = array_map('trim', $parameters);

            $factory = $this->getRuleFactory($factory_name);

            $name = is_string($key) ? $key : $factory_name;
            $validate = $factory($parameters);

            return new Rule($name, $validate);

        }

        // is_callable must be AFTER is_string, otherwise factories named like a
        // php function can't be used (ex: date).
        if (is_callable($definition)) {

            return new Rule((string) $key, $definition);

        }

        throw new InvalidRuleFormatException($definition);
    }
private function parseRuleDefinition ( $ key , $ definition ) : Rule { if ( is_string ( $ definition ) ) { $ parts = preg_split ( '/:/' , $ definition , 2 ) ; $ factory_name = $ parts [ 0 ] ; $ parameters = $ parts [ 1 ] ?? null ; $ parameters = ! is_null ( $ parameters ) ? explode ( ',' , $ parameters ) : [ ] ; $ factory_name = trim ( $ factory_name ) ; $ parameters = array_map ( 'trim' , $ parameters ) ; $ factory = $ this -> getRuleFactory ( $ factory_name ) ; $ name = is_string ( $ key ) ? $ key : $ factory_name ; $ validate = $ factory ( $ parameters ) ; return new Rule ( $ name , $ validate ) ; } // is_callable must be AFTER is_string, otherwise factories named like a // php function can't be used (ex: date). if ( is_callable ( $ definition ) ) { return new Rule ( ( string ) $ key , $ definition ) ; } throw new InvalidRuleFormatException ( $ definition ) ; }
Return a rule from a rule key and the associated definition. It can be
either a callable or a rule factory name with optional parameters.

@param string    $key
@param mixed     $definition
@return \Ellipse\Validation\Rule
Return a rule from a rule key and the associated definition . It can be either a callable or a rule factory name with optional parameters .