From 61418ac1cca698cec63239164d738a99c0b66ba4 Mon Sep 17 00:00:00 2001 From: Victor Garcia <102045600+vgarciaf@users.noreply.github.com> Date: Tue, 9 Jan 2024 12:14:43 +0100 Subject: [PATCH] feat: add has stages (#7) Co-authored-by: Tortitas --- .gitignore | 2 ++ src/PipeLine.php | 5 +++++ tests/PipelineTest.php | 9 +++++++++ 3 files changed, 16 insertions(+) diff --git a/.gitignore b/.gitignore index d10366d..32ead5b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ /vendor /build +/composer-local.json /composer.lock +/composer-local.lock /.php_cs.cache /.phpunit.result.cache /.php-cs-fixer.cache diff --git a/src/PipeLine.php b/src/PipeLine.php index cbdb437..81ae605 100644 --- a/src/PipeLine.php +++ b/src/PipeLine.php @@ -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); diff --git a/tests/PipelineTest.php b/tests/PipelineTest.php index ce30aca..9252879 100644 --- a/tests/PipelineTest.php +++ b/tests/PipelineTest.php @@ -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());