/**
  * @param string $message
  * @return DomainEventStreamInterface
  */
 public function deserialize($message)
 {
     $serializedDomainMessageStream = json_decode($message, true);
     $domainMessages = [];
     foreach ($serializedDomainMessageStream as $serializedDomainMessage) {
         $domainMessages[] = $this->serializer->deserialize($serializedDomainMessage);
     }
     return new DomainEventStream($domainMessages);
 }
 /**
  * @test
  */
 public function it_should_deserialize_an_array_of_domain_messages_and_return_a_stream()
 {
     $event = new DomainMessage('a', 0, new Metadata(), [], DateTime::now());
     $stream = new DomainEventStream([$event]);
     $this->serializer->shouldReceive('deserialize')->with(['serialized'])->andReturn($event);
     $serializer = new JsonDomainEventStreamSerializer($this->serializer);
     $deserialized = $serializer->deserialize('[["serialized"]]');
     $this->assertEquals($stream, $deserialized);
 }