diff --git a/src/Internal/EtlBuilderTrait.php b/src/Internal/EtlBuilderTrait.php index 83f3bdb..29e1ab8 100644 --- a/src/Internal/EtlBuilderTrait.php +++ b/src/Internal/EtlBuilderTrait.php @@ -63,6 +63,6 @@ public function withRecipe(Recipe|callable $recipe): self $recipe = Recipe::fromCallable($recipe); } - return $recipe->fork($this); + return $recipe->decorate($this); } } diff --git a/src/Recipe/LoggerRecipe.php b/src/Recipe/LoggerRecipe.php index 973db4a..a8f0c14 100644 --- a/src/Recipe/LoggerRecipe.php +++ b/src/Recipe/LoggerRecipe.php @@ -48,7 +48,7 @@ public function __construct( ) { } - public function fork(EtlExecutor $executor): EtlExecutor + public function decorate(EtlExecutor $executor): EtlExecutor { return $executor ->onInit(fn (InitEvent $event) => $this->log($event, 'Initializing ETL...', ['state' => $event->state]), diff --git a/src/Recipe/Recipe.php b/src/Recipe/Recipe.php index 7fb44e7..ec45ecb 100644 --- a/src/Recipe/Recipe.php +++ b/src/Recipe/Recipe.php @@ -9,17 +9,17 @@ abstract class Recipe { - abstract public function fork(EtlExecutor $executor): EtlExecutor; + abstract public function decorate(EtlExecutor $executor): EtlExecutor; - public static function fromCallable(callable $recipe): self + final public static function fromCallable(callable $recipe): self { - return new class(Closure::fromCallable($recipe)) extends Recipe { + return new class($recipe(...)) extends Recipe { public function __construct( - private Closure $recipe, + private readonly Closure $recipe, ) { } - public function fork(EtlExecutor $executor): EtlExecutor + public function decorate(EtlExecutor $executor): EtlExecutor { return ($this->recipe)($executor); }