diff --git a/spec/Step/FilterStepSpec.php b/spec/Step/FilterStepSpec.php index 5c0fd8e..062ac87 100644 --- a/spec/Step/FilterStepSpec.php +++ b/spec/Step/FilterStepSpec.php @@ -43,7 +43,7 @@ function it_processes_and_filters_an_item(Step $step) return false; })->shouldReturn($this); - $this->process( + $this->shouldThrow('Port\Steps\Exception\FilterException')->duringProcess( $item, function($item) use ($step, $next) { return $step->process($item, $next); diff --git a/src/Exception/FilterException.php b/src/Exception/FilterException.php new file mode 100644 index 0000000..acad6ad --- /dev/null +++ b/src/Exception/FilterException.php @@ -0,0 +1,15 @@ + + */ +class FilterException extends \Exception implements Exception +{ + +} diff --git a/src/Step/FilterStep.php b/src/Step/FilterStep.php index 11a8cc0..9e80237 100644 --- a/src/Step/FilterStep.php +++ b/src/Step/FilterStep.php @@ -2,6 +2,7 @@ namespace Port\Steps\Step; +use Port\Steps\Exception\FilterException; use Port\Steps\Step; /** @@ -39,7 +40,7 @@ public function process($item, callable $next) { foreach (clone $this->filters as $filter) { if (false === call_user_func($filter, $item)) { - return false; + throw new FilterException(); } } diff --git a/src/StepAggregator.php b/src/StepAggregator.php index c3d1d93..daa714d 100644 --- a/src/StepAggregator.php +++ b/src/StepAggregator.php @@ -9,6 +9,7 @@ use Port\Workflow; use Port\Writer; use Port\Steps\Exception\BreakException; +use Port\Steps\Exception\FilterException; use Psr\Log\LoggerInterface; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; @@ -114,9 +115,9 @@ public function process() // Read all items foreach ($this->reader as $index => $item) { try { - if (false === $pipeline($item)) { - continue; - } + $pipeline($item); + } catch(FilterException $e) { + continue; } catch(BreakException $e) { break; } catch(Exception $e) {