Skip to content

Commit 77f4c12

Browse files
Merge pull request #740 from smrtab/master
Fixes #739 Wrong condition
2 parents dc9dba2 + 6f0b19a commit 77f4c12

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/mail/EmailAddress.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public function __construct(
7070
*/
7171
public function setEmailAddress($emailAddress)
7272
{
73-
if (!is_string($emailAddress) &&
74-
filter_var($emailAddress, FILTER_VALIDATE_EMAIL)
73+
if (!(is_string($emailAddress) &&
74+
filter_var($emailAddress, FILTER_VALIDATE_EMAIL))
7575
) {
7676
throw new TypeException(
7777
'$emailAddress must be valid and of type string.'

test/unit/MailHelperTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,15 @@ public function testEmailName()
7070
'{"name":"\\"O\'Keeffe, John \\\\\\"Billy\\\\\\"\\"","email":"[email protected]"}'
7171
);
7272
}
73+
74+
/**
75+
* This method tests TypeException for wrong email address
76+
*
77+
* @expectedException \SendGrid\Mail\TypeException
78+
*/
79+
public function testEmailAddress()
80+
{
81+
$email = new EmailAddress();
82+
$email->setEmailAddress('[email protected]@wrong');
83+
}
7384
}

0 commit comments

Comments
 (0)