public function toHandler($command)
    {
        $class = get_class($command);
        $offset = ($this->positionAt('Command', $class)) ?: $this->positionAt('Request', $class);
        $handlerClass = substr_replace($class, 'Handler', $offset);

        if (!class_exists($handlerClass)) {
            $message = "Command handler [$handlerClass] does not exist.";
            throw new HandlerNotRegisteredException($message);
        }

        return $handlerClass;
    }