/**
  * @param CollectsEventEnvelopes $commitedEvents
  */
 public final function clearCommittedChanges(CollectsEventEnvelopes $commitedEvents)
 {
     $this->trackedChanges->removeEvents($commitedEvents);
 }
 /**
  * @return CollectsEventEnvelopes
  */
 public function getChanges()
 {
     $changes = new EventEnvelopeCollection();
     foreach ($this->aggregateRoots as $aggregateRoot) {
         if ($aggregateRoot->hasChanges()) {
             $changes->append($aggregateRoot->getChanges());
         }
     }
     $changes->sort($this->getChangesSortFunction());
     return $changes;
 }
 public function testCanAppendCollectionToCollection()
 {
     $collection = new EventEnvelopeCollection();
     $first_event = $this->getTestEvent('Unit-Test-1');
     $second_event = $this->getTestEvent('Unit-Test-2');
     $first_envelope = new EventEnvelope($first_event, []);
     $second_envelope = new EventEnvelope($second_event, []);
     $collection[] = $first_envelope;
     $collection[] = $second_envelope;
     $collection_to_append = new EventEnvelopeCollection();
     $third_event = $this->getTestEvent('Unit-Test-3');
     $fourth_event = $this->getTestEvent('Unit-Test-4');
     $third_envelope = new EventEnvelope($third_event, []);
     $fourth_envelope = new EventEnvelope($fourth_event, []);
     $collection_to_append[] = $third_envelope;
     $collection_to_append[] = $fourth_envelope;
     /** @var EventEnvelopeCollection $collection */
     /** @var EventEnvelopeCollection $collection_to_append */
     $collection->append($collection_to_append);
     $this->assertSame($first_envelope, $collection[0]);
     $this->assertSame($second_envelope, $collection[1]);
     $this->assertSame($third_envelope, $collection[2]);
     $this->assertSame($fourth_envelope, $collection[3]);
 }
 /**
  * @param ServesEventStreamData[] $events
  *
  * @throws Exceptions\NotAnEventEnvelope
  */
 public function __construct(array $events)
 {
     foreach ($events as $event) {
         parent::offsetSet(null, $event);
     }
 }