mirror of
https://github.com/opdavies/gmail-filter-builder.git
synced 2025-11-20 00:38:45 +00:00
wip
This commit is contained in:
parent
caa3767246
commit
ba5a972715
3 changed files with 43 additions and 7 deletions
|
|
@ -275,4 +275,22 @@ class Filter
|
|||
{
|
||||
return $this->properties;
|
||||
}
|
||||
|
||||
public function negate(Filter $filter): self
|
||||
{
|
||||
$filter->properties = collect($filter->toArray())
|
||||
->mapWithKeys(function ($conditions, $key) {
|
||||
return [$key => collect($conditions)->map(function ($condition) {
|
||||
return $this->negateCondition($condition);
|
||||
})];
|
||||
})
|
||||
->toArray();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function negateCondition(string $condition): string
|
||||
{
|
||||
return "-($condition)";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue