code: public function extractPendingStreamEvents($anEventSourcedAggregateRoot): array
      {
          if (null === $this->pendingEventsExtractor) {
              $this->pendingEventsExtractor = function (): array {
                  return $this->popRecordedEvents();
              };
          }
  
          return $this->pendingEventsExtractor->call($anEventSourcedAggregateRoot);
      }
docs: @param object $anEventSourcedAggregateRoot
  
  @return Message[]