Skip to content

Commit

Permalink
feat: new fresh pipeline from existing pipeline
Browse files Browse the repository at this point in the history
Signed-off-by: Mehmet Korkmaz <mehmet@mkorkmaz.com>
  • Loading branch information
mkorkmaz committed May 13, 2024
1 parent 5552eab commit 7457435
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/CaseConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ public static function toSnakeCase(string $source, string $separator = '_'): str

return str_replace(' ', $separator, $lowercase);
}


}
7 changes: 7 additions & 0 deletions src/Pipeline/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,11 @@ private function getArgument(string $argumentName, string $argumentType)
return $this->container->has($argumentType) ? $this->container->get($argumentType) :
$this->container->get($argumentName);
}

public function newPipeline(): PipelineInterface
{
$new = clone $this;
$new->stages = [];
return $new;
}
}
3 changes: 1 addition & 2 deletions src/Pipeline/PipelineInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
interface PipelineInterface
{
public function pipe($stage): PipelineInterface;

public function newPipeline(): PipelineInterface;
public static function withContainer(ContainerInterface $container): self;

public function process($payload);
}

0 comments on commit 7457435

Please sign in to comment.