public function register($name, $handler)
    {
        Assert::string($name, 'The handler name must be a string. Got: %s');
        Assert::notEmpty($name, 'The handler name must not be empty.');

        if (!is_object($handler)) {
            Assert::isCallable($handler, 'The handler must be a callable or an object. Got: %s');
        }

        $this->handlers[$name] = $handler;

        if (!$this->selectedHandler) {
            $this->selectedHandler = $name;
        }
    }
public function register($name, $handler)
    {
        Assert::string($name, 'The handler name must be a string. Got: %s');
        Assert::notEmpty($name, 'The handler name must not be empty.');

        if (!is_object($handler)) {
            Assert::isCallable($handler, 'The handler must be a callable or an object. Got: %s');
        }

        $this->handlers[$name] = $handler;

        if (!$this->selectedHandler) {
            $this->selectedHandler = $name;
        }
    }
public function register ( $ name , $ handler ) { Assert :: string ( $ name , 'The handler name must be a string. Got: %s' ) ; Assert :: notEmpty ( $ name , 'The handler name must not be empty.' ) ; if ( ! is_object ( $ handler ) ) { Assert :: isCallable ( $ handler , 'The handler must be a callable or an object. Got: %s' ) ; } $ this -> handlers [ $ name ] = $ handler ; if ( ! $ this -> selectedHandler ) { $ this -> selectedHandler = $ name ; } }
Registers a command handler for the given name.

@param string          $name    The handler name.
@param object|callable $handler The handler or a factory callback that
creates the handler.
Registers a command handler for the given name .