src/Transformer/CommandTransformer.php
public function transformCommandToMessage($command)
    {
        if (!is_object($command)) {
            throw CommandTransformationException::expectedObject($command);
        }
        if (!isset($this->commands[get_class($command)])) {
            throw CommandTransformationException::unknownCommand($command, array_keys($this->commands));
        }
        if ($this->serializer instanceof EncoderInterface && !$this->serializer->supportsEncoding($this->format)) {
            throw CommandTransformationException::unsupportedFormat($command, $this->format);
        }

        $info = $this->commands[get_class($command)];

        return new CommandMessage(
            $info->getVhost(),
            $info->getExchange(),
            $this->serializer->serialize($command, $this->format),
            $info->getRoutingKey(),
            $info->getFlags(),
            $this->resolveMessageAttributes($command, $info)
        );
    }
public function transformCommandToMessage($command)
    {
        if (!is_object($command)) {
            throw CommandTransformationException::expectedObject($command);
        }
        if (!isset($this->commands[get_class($command)])) {
            throw CommandTransformationException::unknownCommand($command, array_keys($this->commands));
        }
        if ($this->serializer instanceof EncoderInterface && !$this->serializer->supportsEncoding($this->format)) {
            throw CommandTransformationException::unsupportedFormat($command, $this->format);
        }

        $info = $this->commands[get_class($command)];

        return new CommandMessage(
            $info->getVhost(),
            $info->getExchange(),
            $this->serializer->serialize($command, $this->format),
            $info->getRoutingKey(),
            $info->getFlags(),
            $this->resolveMessageAttributes($command, $info)
        );
    }
Returns a Message instance representation of a command

@param mixed $command The command to transform
@return CommandMessage