mirror of
https://github.com/retailcrm/transparent-email.git
synced 2024-11-25 23:06:04 +03:00
Support for yahoo.com
This commit is contained in:
parent
7bfd541973
commit
1aa23920fd
@ -12,6 +12,7 @@ Gordianus clears aliases from email address. Email `John.Doe+alias@gmail.com` wi
|
|||||||
* [tlen.pl](http://tlen.pl)
|
* [tlen.pl](http://tlen.pl)
|
||||||
* [33mail.com](https://www.33mail.com)
|
* [33mail.com](https://www.33mail.com)
|
||||||
* [outlook.com](http://outlook.com)
|
* [outlook.com](http://outlook.com)
|
||||||
|
* [yahoo.com](http://mail.yahoo.com)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ use bkrukowski\Gordianus\Services\OutlookCom;
|
|||||||
use bkrukowski\Gordianus\Services\ServiceInterface;
|
use bkrukowski\Gordianus\Services\ServiceInterface;
|
||||||
use bkrukowski\Gordianus\Services\TlenPl;
|
use bkrukowski\Gordianus\Services\TlenPl;
|
||||||
use bkrukowski\Gordianus\Services\Www33MailCom;
|
use bkrukowski\Gordianus\Services\Www33MailCom;
|
||||||
|
use bkrukowski\Gordianus\Services\YahooCom;
|
||||||
|
|
||||||
class Gordianus
|
class Gordianus
|
||||||
{
|
{
|
||||||
@ -14,6 +15,7 @@ class Gordianus
|
|||||||
const SERVICE_TLEN_PL = TlenPl::class;
|
const SERVICE_TLEN_PL = TlenPl::class;
|
||||||
const SERVICE_WWW_33MAIL_COM = Www33MailCom::class;
|
const SERVICE_WWW_33MAIL_COM = Www33MailCom::class;
|
||||||
const SERVICE_OUTLOOK_COM = OutlookCom::class;
|
const SERVICE_OUTLOOK_COM = OutlookCom::class;
|
||||||
|
const SERVICE_YAHOO_COM = YahooCom::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant ALL_SERVICES can contain different values depends on API version
|
* Constant ALL_SERVICES can contain different values depends on API version
|
||||||
@ -23,6 +25,7 @@ class Gordianus
|
|||||||
self::SERVICE_TLEN_PL,
|
self::SERVICE_TLEN_PL,
|
||||||
self::SERVICE_WWW_33MAIL_COM,
|
self::SERVICE_WWW_33MAIL_COM,
|
||||||
self::SERVICE_OUTLOOK_COM,
|
self::SERVICE_OUTLOOK_COM,
|
||||||
|
self::SERVICE_YAHOO_COM,
|
||||||
];
|
];
|
||||||
|
|
||||||
private $services;
|
private $services;
|
||||||
|
22
src/Services/YahooCom.php
Normal file
22
src/Services/YahooCom.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace bkrukowski\Gordianus\Services;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
class YahooCom implements ServiceInterface
|
||||||
|
{
|
||||||
|
public function getPrimaryEmail(string $email) : string
|
||||||
|
{
|
||||||
|
list($name, $domain) = explode('@', strtolower($email));
|
||||||
|
$explodedName = explode('-', $name, 2);
|
||||||
|
|
||||||
|
return $explodedName[0] . (count($explodedName) === 2 ? '-alias' : '') . '@' . $domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isDomainSupported(string $domain) : bool
|
||||||
|
{
|
||||||
|
return strtolower($domain) === 'yahoo.com';
|
||||||
|
}
|
||||||
|
}
|
@ -50,6 +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'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
55
tests/Services/YahooComTest.php
Normal file
55
tests/Services/YahooComTest.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace bkrukowski\Gordianus\Tests\Services;
|
||||||
|
|
||||||
|
use bkrukowski\Gordianus\Services\YahooCom;
|
||||||
|
|
||||||
|
class YahooComTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @dataProvider providerIsDomainSupported
|
||||||
|
*
|
||||||
|
* @param string $domain
|
||||||
|
* @param bool $result
|
||||||
|
*/
|
||||||
|
public function testIsDomainSupported(string $domain, bool $result)
|
||||||
|
{
|
||||||
|
$this->assertSame($result, (new YahooCom())->isDomainSupported($domain));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function providerIsDomainSupported()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['yahoo.com', true],
|
||||||
|
['Yahoo.Com', true],
|
||||||
|
['YAHOO.COM', true],
|
||||||
|
['hotmail.com', false],
|
||||||
|
['HotMail.COM', false],
|
||||||
|
['gmail.com', false],
|
||||||
|
['tlen.pl', false],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerGetPrimaryEmail
|
||||||
|
*
|
||||||
|
* @param string $inputEmail
|
||||||
|
* @param string $expectedEmail
|
||||||
|
*/
|
||||||
|
public function testGetPrimaryEmail(string $inputEmail, string $expectedEmail)
|
||||||
|
{
|
||||||
|
$this->assertSame($expectedEmail, (new YahooCom())->getPrimaryEmail($inputEmail));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function providerGetPrimaryEmail()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['janedoe@yahoo.com', 'janedoe@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-alias@yahoo.com'],
|
||||||
|
['Jane.Doe-spam-alias@YAHOO.COM', 'jane.doe-alias@yahoo.com'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user