Skip to content

Commit 420a9fd

Browse files
committed
Added additional recipient validation check
1 parent 3c7b4fa commit 420a9fd

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/Validator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ private function validateRecipient(EmailComposer $composer)
6767

6868
$recipients = (array) $composer->getData('recipient');
6969

70+
if (count($recipients) == 0) {
71+
throw new InvalidArgumentException('No recipient specified');
72+
}
73+
7074
foreach ($recipients as $recipient) {
7175
if (! filter_var($recipient, FILTER_VALIDATE_EMAIL)) {
7276
throw new InvalidArgumentException('E-mail address [' . $recipient . '] is invalid');

tests/ValidatorTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ public function a_recipient_is_required()
3030
->send();
3131
}
3232

33+
/**
34+
* @test
35+
* @expectedException InvalidArgumentException
36+
* @expectedExceptionMessage No recipient specified
37+
*/
38+
public function a_recipient_cannot_be_empty()
39+
{
40+
Email::compose()
41+
->recipient([])
42+
->send();
43+
}
44+
3345
/**
3446
* @test
3547
* @expectedException InvalidArgumentException

0 commit comments

Comments
 (0)