diff --git a/src/Model/FilterGroup.php b/src/Model/FilterGroup.php new file mode 100644 index 0000000..6f40ebb --- /dev/null +++ b/src/Model/FilterGroup.php @@ -0,0 +1,37 @@ +filters = new Collection(); + } + + public static function if(Filter $filter): self + { + $self = new static(); + + $self->filters->push($filter); + + return $self; + } + + public function otherwise(Filter $filter): self + { + $this->filters->push($filter); + + return $this; + } + + public function toArray(): array + { + return $this->filters->toArray(); + } +} diff --git a/tests/OtherwiseTest.php b/tests/OtherwiseTest.php new file mode 100644 index 0000000..238bbc0 --- /dev/null +++ b/tests/OtherwiseTest.php @@ -0,0 +1,31 @@ +has('to:me@example.com foo') + ->labelAndArchive('Test') + )->otherwise( + Filter::create() + ->has('to:me@example.com bar') + ->read() + )->otherwise( + Filter::create() + ->has('to:me@example.com') + ->trash() + ); + + $this->assertCount(3, $filters->toArray()); + } +}