src/EventStoreIntegration/ClosureAggregateTranslator.php
public function reconstituteAggregateFromHistory(AggregateType $aggregateType, Iterator $historyEvents)
    {
        if (null === $this->aggregateReconstructor) {
            $this->aggregateReconstructor = function ($historyEvents) {
                return static::reconstituteFromHistory($historyEvents);
            };
        }

        $arClass = $aggregateType->toString();

        if (! \class_exists($arClass)) {
            throw new RuntimeException(
                \sprintf('Aggregate root class %s cannot be found', $arClass)
            );
        }

        return ($this->aggregateReconstructor->bindTo(null, $arClass))($historyEvents);
    }
public function reconstituteAggregateFromHistory(AggregateType $aggregateType, Iterator $historyEvents)
    {
        if (null === $this->aggregateReconstructor) {
            $this->aggregateReconstructor = function ($historyEvents) {
                return static::reconstituteFromHistory($historyEvents);
            };
        }

        $arClass = $aggregateType->toString();

        if (! \class_exists($arClass)) {
            throw new RuntimeException(
                \sprintf('Aggregate root class %s cannot be found', $arClass)
            );
        }

        return ($this->aggregateReconstructor->bindTo(null, $arClass))($historyEvents);
    }
@param AggregateType $aggregateType
@param Iterator $historyEvents

@return object reconstructed AggregateRoot