src/Etl.php
private function transform($item, $key)
    {
        $transformed = ($this->transform)($item, $key, $this);

        if (!$transformed instanceof \Generator) {
            throw new EtlException('The transformer must return a generator.');
        }

        // Traverse generator to trigger events
        try {
            $transformed = \iterator_to_array($transformed);
            $this->eventDispatcher->dispatch(new ItemEvent(EtlEvents::TRANSFORM, $item, $key, $this));
        } catch (\Exception $e) {
            /** @var ItemExceptionEvent $event */
            $event = $this->eventDispatcher->dispatch(new ItemExceptionEvent(EtlEvents::TRANSFORM_EXCEPTION, $item, $key, $this, $e));
            if ($event->shouldThrowException()) {
                throw $e;
            }
        }

        return function () use ($transformed) {
            yield from $transformed;
        };
    }
private function transform($item, $key)
    {
        $transformed = ($this->transform)($item, $key, $this);

        if (!$transformed instanceof \Generator) {
            throw new EtlException('The transformer must return a generator.');
        }

        // Traverse generator to trigger events
        try {
            $transformed = \iterator_to_array($transformed);
            $this->eventDispatcher->dispatch(new ItemEvent(EtlEvents::TRANSFORM, $item, $key, $this));
        } catch (\Exception $e) {
            /** @var ItemExceptionEvent $event */
            $event = $this->eventDispatcher->dispatch(new ItemExceptionEvent(EtlEvents::TRANSFORM_EXCEPTION, $item, $key, $this, $e));
            if ($event->shouldThrowException()) {
                throw $e;
            }
        }

        return function () use ($transformed) {
            yield from $transformed;
        };
    }
private function transform ( $ item , $ key ) { $ transformed = ( $ this -> transform ) ( $ item , $ key , $ this ) ; if ( ! $ transformed instanceof \ Generator ) { throw new EtlException ( 'The transformer must return a generator.' ) ; } // Traverse generator to trigger events try { $ transformed = \ iterator_to_array ( $ transformed ) ; $ this -> eventDispatcher -> dispatch ( new ItemEvent ( EtlEvents :: TRANSFORM , $ item , $ key , $ this ) ) ; } catch ( \ Exception $ e ) { /** @var ItemExceptionEvent $event */ $ event = $ this -> eventDispatcher -> dispatch ( new ItemExceptionEvent ( EtlEvents :: TRANSFORM_EXCEPTION , $ item , $ key , $ this , $ e ) ) ; if ( $ event -> shouldThrowException ( ) ) { throw $ e ; } } return function ( ) use ( $ transformed ) { yield from $ transformed ; } ; }
Transform data.

@param $item
@param $key
@return callable
@throws EtlException
Transform data .