Support for yahoo.com

This commit is contained in:
bkrukowski 2016-09-10 14:45:30 +02:00
parent 9fe033a431
commit cbaf122289
4 changed files with 6 additions and 6 deletions

View File

@ -37,4 +37,5 @@ Yahoo uses the following pattern[*](https://help.yahoo.com/kb/SLN16026.html):
* *baseName* - value defined by the user, different than email login; * *baseName* - value defined by the user, different than email login;
* *keyword* - one from a list of keywords defined by the user. * *keyword* - one from a list of keywords defined by the user.
Therefore we do not know what is the real email, so in this case result will be `baseName-alias@yahoo.com`. Therefore we do not know what is the real email, so in this case result will be `baseName@yahoo.com`,
which actually does not exist.

View File

@ -10,9 +10,8 @@ class YahooCom implements ServiceInterface
public function getPrimaryEmail(string $email) : string public function getPrimaryEmail(string $email) : string
{ {
list($name, $domain) = explode('@', strtolower($email)); list($name, $domain) = explode('@', strtolower($email));
$explodedName = explode('-', $name, 2);
return $explodedName[0] . (count($explodedName) === 2 ? '-alias' : '') . '@' . $domain; return explode('-', $name, 2)[0] . '@' . $domain;
} }
public function isDomainSupported(string $domain) : bool public function isDomainSupported(string $domain) : bool

View File

@ -50,7 +50,7 @@ class GordianusTest extends \PHPUnit_Framework_TestCase
[new Gordianus([], true), 'John.Doe@example.com', 'John.Doe@example.com'], [new Gordianus([], true), 'John.Doe@example.com', 'John.Doe@example.com'],
[new Gordianus(Gordianus::ALL_SERVICES, true), 'John.Doe@gmail.com', 'johndoe@gmail.com'], [new Gordianus(Gordianus::ALL_SERVICES, true), 'John.Doe@gmail.com', 'johndoe@gmail.com'],
[new Gordianus(), 'Jane.Doe+receipts@hotmail.com', 'jane.doe@hotmail.com'], [new Gordianus(), 'Jane.Doe+receipts@hotmail.com', 'jane.doe@hotmail.com'],
[new Gordianus(), 'Jane.Doe-receipts@yahoo.com', 'jane.doe-alias@yahoo.com'], [new Gordianus(), 'Jane.Doe-receipts@yahoo.com', 'jane.doe@yahoo.com'],
]; ];
} }
} }

View File

@ -48,8 +48,8 @@ class YahooComTest extends \PHPUnit_Framework_TestCase
['jane.doe@yahoo.com', 'jane.doe@yahoo.com'], ['jane.doe@yahoo.com', 'jane.doe@yahoo.com'],
['Jane.Doe@Yahoo.Com', 'jane.doe@yahoo.com'], ['Jane.Doe@Yahoo.Com', 'jane.doe@yahoo.com'],
['Jane.Doe+receipts@YAHOO.COM', 'jane.doe+receipts@yahoo.com'], ['Jane.Doe+receipts@YAHOO.COM', 'jane.doe+receipts@yahoo.com'],
['Jane.Doe-receipts@YAHOO.COM', 'jane.doe-alias@yahoo.com'], ['Jane.Doe-receipts@YAHOO.COM', 'jane.doe@yahoo.com'],
['Jane.Doe-spam-alias@YAHOO.COM', 'jane.doe-alias@yahoo.com'], ['Jane.Doe-spam-alias@YAHOO.COM', 'jane.doe@yahoo.com'],
]; ];
} }
} }