/**
  * @test
  */
 public function it_should_fail_when_no_message_is_returned()
 {
     $command = new \stdClass();
     $this->middleware->addSupportedCommand('\\stdClass');
     $this->transformer->shouldReceive('transformCommandToMessage')->atLeast()->once()->with($command)->andReturn(null);
     $this->setExpectedException(CommandTransformationException::class);
     $this->middleware->execute($command, function () {
         throw new \LogicException('Next should not have been called!');
     });
 }
 /**
  * {@inheritdoc}
  */
 public function execute($command, callable $next)
 {
     if (!is_object($command) || !in_array(get_class($command), $this->commands, true)) {
         return $next($command);
     }
     $message = $this->transformer->transformCommandToMessage($command);
     if (!$message instanceof Message) {
         throw CommandTransformationException::invalidMessageFromTransformer($message, $command);
     }
     return $next($message);
 }