Skip to content

Commit

Permalink
refactor: rename recipe main method
Browse files Browse the repository at this point in the history
  • Loading branch information
bpolaszek committed Nov 8, 2023
1 parent f45cf5d commit 5d1807d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Internal/EtlBuilderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ public function withRecipe(Recipe|callable $recipe): self
$recipe = Recipe::fromCallable($recipe);
}

return $recipe->fork($this);
return $recipe->decorate($this);
}
}
2 changes: 1 addition & 1 deletion src/Recipe/LoggerRecipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand Down
10 changes: 5 additions & 5 deletions src/Recipe/Recipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 5d1807d

Please sign in to comment.