src/RuleSet/RuleSetContainer.php
public function set($keyword, $factory)
    {
        if (!(is_string($factory) || $factory instanceof \Closure)) {
            throw new \InvalidArgumentException(
                sprintf('Expected a string or Closure, got %s', gettype($keyword))
            );
        }

        $this->rules[$keyword] = function ($container) use ($factory) {
            static $object;

            if (is_null($object)) {
                $object = is_string($factory) ? new $factory() : $factory($container);
            }

            return $object;
        };
    }
public function set($keyword, $factory)
    {
        if (!(is_string($factory) || $factory instanceof \Closure)) {
            throw new \InvalidArgumentException(
                sprintf('Expected a string or Closure, got %s', gettype($keyword))
            );
        }

        $this->rules[$keyword] = function ($container) use ($factory) {
            static $object;

            if (is_null($object)) {
                $object = is_string($factory) ? new $factory() : $factory($container);
            }

            return $object;
        };
    }
public function set ( $ keyword , $ factory ) { if ( ! ( is_string ( $ factory ) || $ factory instanceof \ Closure ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Expected a string or Closure, got %s' , gettype ( $ keyword ) ) ) ; } $ this -> rules [ $ keyword ] = function ( $ container ) use ( $ factory ) { static $ object ; if ( is_null ( $ object ) ) { $ object = is_string ( $ factory ) ? new $ factory ( ) : $ factory ( $ container ) ; } return $ object ; } ; }
Adds a rule to the container.

@param string          $keyword Identifier of the entry.
@param \Closure|string $factory The closure to invoke when this entry is resolved or the FQCN.
The closure will be given this container as the only
argument when invoked.
Adds a rule to the container .