Allow for passing multiple lists

This commit is contained in:
Oliver Davies 2019-04-10 23:34:16 +01:00
parent 035f4fb6c7
commit 0b225663e0
2 changed files with 10 additions and 1 deletions

View file

@ -4,6 +4,9 @@ namespace Opdavies\GmailFilterBuilder\Model;
class Filter
{
/** @var string */
const SEPARATOR = '|';
/**
* @var array
*/
@ -100,12 +103,13 @@ class Filter
/**
* Filter a message if it was sent from a mailing list.
*
* @param $value The mailing list address
* @param string|array $value The mailing list address
*
* @return $this
*/
public function fromList($value)
{
$value = collect($value)->implode(self::SEPARATOR);
$this->has("list:{$value}");
return $this;

View file

@ -143,6 +143,11 @@ class FilterTest extends TestCase
['hasTheWord' => 'list:foobar'],
$this->filter->fromList('foobar')->toArray()
);
$this->assertEquals(
['hasTheWord' => 'list:list-one.com|list-two.com'],
$this->filter->fromList(['list-one.com', 'list-two.com'])->toArray()
);
}
/**