Skip to content

Commit

Permalink
feat: add has stages (#7)
Browse files Browse the repository at this point in the history
Co-authored-by: Tortitas <victorgf2011@gmail.com>
  • Loading branch information
vgarciaf and TortitasT authored Jan 9, 2024
1 parent bec2ebc commit 61418ac
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/vendor
/build
/composer-local.json
/composer.lock
/composer-local.lock
/.php_cs.cache
/.phpunit.result.cache
/.php-cs-fixer.cache
5 changes: 5 additions & 0 deletions src/PipeLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public function process($payload, array $options = [])
return $payload;
}

public function hasStages(): bool
{
return count($this->stages) > 0;
}

private function processStage(Stage $stage, $payload, $options)
{
$stage->options($options);
Expand Down
9 changes: 9 additions & 0 deletions tests/PipelineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ public function testPipeline()
$this->assertEquals(10, ThreePipeline::getInstance()->process(10));
}

public function testHasStages()
{
$this->injections();

$this->assertTrue(OnePipeline::getInstance()->hasStages());
$this->assertTrue(TwoPipeline::getInstance()->hasStages());
$this->assertFalse(ThreePipeline::getInstance()->hasStages());
}

private function injections()
{
OnePipeline::getInstance()->pipe(new DoubleStage())->pipe(new IncreaseStage());
Expand Down

0 comments on commit 61418ac

Please sign in to comment.