mirror of
https://github.com/opdavies/gmail-filter-builder.git
synced 2025-02-02 00:47:32 +00:00
Merge pull request #18 from opdavies/multiple-lists-17
Allow for filtering multiple lists in one filter Fixes #17
This commit is contained in:
commit
1b99194e35
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue