Ejemplo n.º 1
0
 /**
  * @throws InvalidTypeInCollection
  */
 private function ensureCollectionContainsEvents()
 {
     foreach ($this->events as $event) {
         if (!$event instanceof DomainEvent) {
             throw InvalidTypeInCollection::create($event, 'SimpleES\\EventSourcing\\Event\\DomainEvent');
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * @throws InvalidTypeInCollection
  * @throws EventStreamIsCorrupt
  */
 private function ensureCollectionContainsEnvelopesWithSameAggregateId()
 {
     foreach ($this->envelopes as $envelope) {
         if (!$envelope instanceof EnvelopsEvent) {
             throw InvalidTypeInCollection::create($envelope, 'SimpleES\\EventSourcing\\Event\\EnvelopsEvent');
         }
         if (!$envelope->aggregateId()->equals($this->aggregateId)) {
             throw EventStreamIsCorrupt::create($envelope->aggregateId(), $this->aggregateId);
         }
     }
 }
 /**
  * @param string $expected
  * @param string $actual
  * @throws InvalidTypeInCollection
  */
 private function ensureInstanceOf($expected, $actual)
 {
     if (!is_string($actual) || !is_subclass_of($actual, $expected)) {
         throw InvalidTypeInCollection::create($actual, $expected);
     }
 }
 /**
  * @param mixed $metadataEnricher
  * @throws InvalidTypeInCollection
  */
 private function guardMetadataEnricherType($metadataEnricher)
 {
     if (!$metadataEnricher instanceof EnrichesMetadata) {
         throw InvalidTypeInCollection::create($metadataEnricher, 'SimpleES\\EventSourcing\\Metadata\\EnrichesMetadata');
     }
 }