mirror of
https://github.com/opdavies/gmail-filter-builder.git
synced 2025-09-06 05:25:33 +01:00
A filter group contains the correct number of filters
This commit is contained in:
parent
7cabd2fb2f
commit
af985e8b37
2 changed files with 68 additions and 0 deletions
37
src/Model/FilterGroup.php
Normal file
37
src/Model/FilterGroup.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Opdavies\GmailFilterBuilder\Model;
|
||||
|
||||
use Tightenco\Collect\Support\Collection;
|
||||
|
||||
class FilterGroup
|
||||
{
|
||||
/** @var Collection */
|
||||
private $filters;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue