src/Application/Messaging/Command/Routing/ServiceAwareCommandMap.php
public function registerHandler(string $commandClass, string $serviceName): void
    {
        if (!Validate::implementsInterface($commandClass, Command::class)) {
            $message = sprintf('Invalid command class: %s', $commandClass);
            throw new DomainException($message);
        }

        $type = Type::create($commandClass)->toString();

        $this->handlers[$type] = $serviceName;
    }
public function registerHandler(string $commandClass, string $serviceName): void
    {
        if (!Validate::implementsInterface($commandClass, Command::class)) {
            $message = sprintf('Invalid command class: %s', $commandClass);
            throw new DomainException($message);
        }

        $type = Type::create($commandClass)->toString();

        $this->handlers[$type] = $serviceName;
    }
public function registerHandler ( string $ commandClass , string $ serviceName ) : void { if ( ! Validate :: implementsInterface ( $ commandClass , Command :: class ) ) { $ message = sprintf ( 'Invalid command class: %s' , $ commandClass ) ; throw new DomainException ( $ message ) ; } $ type = Type :: create ( $ commandClass ) -> toString ( ) ; $ this -> handlers [ $ type ] = $ serviceName ; }
Registers a command handler

@param string $commandClass The full command class name
@param string $serviceName  The handler service name

@return void

@throws DomainException When the command class is not valid
Registers a command handler