mirror of
https://github.com/opdavies/gmail-filter-builder.git
synced 2025-09-04 04:35:33 +01:00
Add docblocks, small fixes
This commit is contained in:
parent
9097da2972
commit
728d284f09
3 changed files with 101 additions and 13 deletions
|
@ -4,8 +4,16 @@ namespace Opdavies\GmailFilterBuilder;
|
|||
|
||||
class Filter
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $properties = [];
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function has($value)
|
||||
{
|
||||
$this->properties['hasTheWord'] = $value;
|
||||
|
@ -13,6 +21,11 @@ class Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function hasNot($value)
|
||||
{
|
||||
$this->properties['doesNotHaveTheWord'] = $value;
|
||||
|
@ -20,26 +33,39 @@ class Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $values
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function from($values)
|
||||
{
|
||||
$this->properties['from'] = collect($values)
|
||||
->map(function ($value) {
|
||||
return trim($value);
|
||||
})->all();
|
||||
$this->properties['from'] = collect($values)->map(function ($value) {
|
||||
return trim($value);
|
||||
})->all();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array $values
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function to($values)
|
||||
{
|
||||
$this->properties['to'] = collect($values)
|
||||
->map(function ($value) {
|
||||
return trim($value);
|
||||
})->all();
|
||||
$this->properties['to'] = collect($values)->map(function ($value) {
|
||||
return trim($value);
|
||||
})->all();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subject
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function subject($subject)
|
||||
{
|
||||
$this->properties['subject'] = $subject;
|
||||
|
@ -47,6 +73,9 @@ class Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function hasAttachment()
|
||||
{
|
||||
$this->properties['hasAttachment'] = 'true';
|
||||
|
@ -54,6 +83,9 @@ class Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function excludeChats()
|
||||
{
|
||||
$this->properties['excludeChats'] = 'true';
|
||||
|
@ -61,6 +93,11 @@ class Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $label
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function label($label)
|
||||
{
|
||||
$this->properties['label'] = $label;
|
||||
|
@ -68,6 +105,9 @@ class Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function archive()
|
||||
{
|
||||
$this->properties['shouldArchive'] = 'true';
|
||||
|
@ -75,6 +115,11 @@ class Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $label
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function labelAndArchive($label)
|
||||
{
|
||||
$this->label($label)->archive();
|
||||
|
@ -82,6 +127,9 @@ class Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function spam()
|
||||
{
|
||||
$this->properties['shouldSpam'] = 'true';
|
||||
|
@ -90,6 +138,9 @@ class Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function neverSpam()
|
||||
{
|
||||
$this->properties['shouldSpam'] = 'false';
|
||||
|
@ -98,6 +149,9 @@ class Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function trash()
|
||||
{
|
||||
$this->properties['shouldTrash'] = 'true';
|
||||
|
@ -105,6 +159,9 @@ class Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function read()
|
||||
{
|
||||
$this->properties['markAsRead'] = 'true';
|
||||
|
@ -112,6 +169,9 @@ class Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function star()
|
||||
{
|
||||
$this->properties['shouldStar'] = 'true';
|
||||
|
@ -119,6 +179,11 @@ class Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $to
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function forward($to)
|
||||
{
|
||||
$this->properties['forwardTo'] = $to;
|
||||
|
@ -126,6 +191,9 @@ class Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function important()
|
||||
{
|
||||
$this->properties['shouldAlwaysMarkAsImportant'] = 'true';
|
||||
|
@ -133,6 +201,9 @@ class Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function notImportant()
|
||||
{
|
||||
$this->properties['shouldNeverMarkAsImportant'] = 'true';
|
||||
|
@ -140,6 +211,11 @@ class Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $category
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function categorise($category)
|
||||
{
|
||||
$this->properties['smartLabelToApply'] = $category;
|
||||
|
@ -147,6 +223,9 @@ class Filter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getProperties()
|
||||
{
|
||||
return $this->properties;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue