Skip to content

Commit

Permalink
Revert "refactor: use a while loop"
Browse files Browse the repository at this point in the history
This reverts commit 999e77c
  • Loading branch information
bpolaszek committed Nov 6, 2023
1 parent 689dd06 commit 72d1c71
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/EtlExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use Bentools\ETL\Transformer\NullTransformer;
use Bentools\ETL\Transformer\TransformerInterface;
use Generator;
use IteratorIterator;
use Psr\EventDispatcher\EventDispatcherInterface;
use Throwable;

Expand Down Expand Up @@ -68,17 +67,11 @@ public function process(mixed $source = null, mixed $destination = null): EtlSta
try {
$this->dispatch(new InitEvent($state));

$iterator = new IteratorIterator($this->extract($stateHolder));
$iterator->rewind();
$state = unref($stateHolder);
while ($iterator->valid()) {
$extractedItem = $iterator->current();
foreach ($this->extract($stateHolder) as $extractedItem) {
try {
$transformedItems = $this->transform($extractedItem, $state);
$this->load($transformedItems, $stateHolder);
} catch (SkipRequest) {
} finally {
$iterator->next();
}
}
} catch (StopRequest) {
Expand Down

0 comments on commit 72d1c71

Please sign in to comment.