gmail-filter-builder/src/Filter.php

75 lines
1.3 KiB
PHP
Raw Normal View History

2017-11-03 11:23:22 +00:00
<?php
namespace Opdavies\GmailFilterBuilder;
class Filter
{
2017-11-03 23:22:13 +00:00
private $properties = [];
2017-11-03 11:23:22 +00:00
public function has($value)
{
2017-11-03 23:22:13 +00:00
$this->properties['hasTheWord'] = $value;
return $this;
2017-11-03 11:23:22 +00:00
}
public function from()
{
2017-11-03 23:22:13 +00:00
$this->properties['from'] = collect(func_get_args())
->map(function ($address) {
return trim($address);
})->implode(',');
return $this;
2017-11-03 11:23:22 +00:00
}
public function label($label)
{
2017-11-03 23:22:13 +00:00
$this->properties['label'] = $label;
return $this;
2017-11-03 11:23:22 +00:00
}
public function archive()
{
2017-11-03 23:22:13 +00:00
$this->properties['shouldArchive'] = 'true';
return $this;
2017-11-03 11:23:22 +00:00
}
public function labelAndArchive($label)
{
2017-11-03 23:22:13 +00:00
$this->label($label)->archive();
return $this;
2017-11-03 11:23:22 +00:00
}
public function spam()
{
2017-11-03 23:22:13 +00:00
$this->properties['shouldSpam'] = 'true';
$this->properties['shouldNeverSpam'] = 'false';
return $this;
2017-11-03 11:23:22 +00:00
}
public function neverSpam()
{
2017-11-03 23:22:13 +00:00
$this->properties['shouldSpam'] = 'false';
$this->properties['shouldNeverSpam'] = 'true';
return $this;
2017-11-03 11:23:22 +00:00
}
public function trash()
{
2017-11-03 23:22:13 +00:00
$this->properties['shouldTrash'] = 'true';
return $this;
}
public function getProperties()
{
return $this->properties;
2017-11-03 11:23:22 +00:00
}
}