A filter group contains the correct number of filters

This commit is contained in:
Oliver Davies 2019-04-01 18:18:33 +01:00
parent 7cabd2fb2f
commit af985e8b37
2 changed files with 68 additions and 0 deletions

37
src/Model/FilterGroup.php Normal file
View 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();
}
}