public function applyChanges(AggregateInterface $aggregate): AggregateInterface
    {
        // Execute the handlers of pending Events.
        /**
         * @var EventInterface $event
         */
        foreach ($aggregate->getPendingEvents() as $event) {
            /**
             * Get Handler for Command.
             *
             * @var HandlerInterface $handler
             */
            $handlerClass = $event->getCommand()->getHandlerClass();
            $handler = new $handlerClass($this->messageBus, $this);
            $aggregate = $handler->executeHandler($event->getCommand(), $aggregate);
        }

        // Clear pending events.
        $aggregate->setPendingEvents([]);

        return $aggregate;
    }