Change to and from to use strings or arrays

This commit is contained in:
Oliver Davies 2017-12-30 10:49:31 +00:00
parent 02dddbdaf6
commit 9097da2972
3 changed files with 12 additions and 12 deletions

View file

@ -20,21 +20,21 @@ class Filter
return $this;
}
public function from()
public function from($values)
{
$this->properties['from'] = collect(func_get_args())
->map(function ($address) {
return trim($address);
$this->properties['from'] = collect($values)
->map(function ($value) {
return trim($value);
})->all();
return $this;
}
public function to()
public function to($values)
{
$this->properties['to'] = collect(func_get_args())
->map(function ($address) {
return trim($address);
$this->properties['to'] = collect($values)
->map(function ($value) {
return trim($value);
})->all();
return $this;

View file

@ -9,7 +9,7 @@ class BuilderTest extends TestCase
public function testBuild()
{
$filterA = (new Filter())
->from('foo@example.com', 'test@example.com')
->from(['foo@example.com', 'test@example.com'])
->label('Some label')
->archive();

View file

@ -55,7 +55,7 @@ class FilterTest extends TestCase
// Ensure that we can set multiple from addresses.
$this->assertEquals(
['from' => ['foo@example.com', 'bar@example.com']],
$this->filter->from('foo@example.com', 'bar@example.com')
$this->filter->from(['foo@example.com', 'bar@example.com'])
->getProperties()
);
}
@ -72,7 +72,7 @@ class FilterTest extends TestCase
$this->assertEquals(
['to' => ['bar@example.com', 'baz@example.com']],
$this->filter->to('bar@example.com', 'baz@example.com')
$this->filter->to(['bar@example.com', 'baz@example.com'])
->getProperties()
);
}
@ -240,7 +240,7 @@ class FilterTest extends TestCase
'shouldStar' => 'true',
'shouldAlwaysMarkAsImportant' => 'true',
],
$this->filter->from('foo@example.com ', 'bar@example.com')
$this->filter->from(['foo@example.com ', 'bar@example.com'])
->has('Something')
->excludeChats()
->labelAndArchive('Foo')