mirror of
https://github.com/retailcrm/transparent-email.git
synced 2024-11-21 21:06:04 +03:00
Add Icloud.com service support
This commit is contained in:
parent
dc65847371
commit
2e4cd9ff47
21
src/Services/IcloudCom.php
Normal file
21
src/Services/IcloudCom.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\TransparentEmail\Services;
|
||||
|
||||
use bkrukowski\TransparentEmail\Emails\EditableEmail;
|
||||
use bkrukowski\TransparentEmail\Emails\EmailInterface;
|
||||
|
||||
class IcloudCom implements ServiceInterface
|
||||
{
|
||||
public function getPrimaryEmail(EmailInterface $email) : EmailInterface
|
||||
{
|
||||
return (new EditableEmail($email))
|
||||
->removeSuffixAlias('+')
|
||||
->lowerCaseLocalPartIf(true);
|
||||
}
|
||||
|
||||
public function isSupported(EmailInterface $email) : bool
|
||||
{
|
||||
return in_array($email->getDomain(), ['icloud.com']);
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ namespace bkrukowski\TransparentEmail;
|
||||
use bkrukowski\TransparentEmail\Services\AppsGoogleCom;
|
||||
use bkrukowski\TransparentEmail\Services\GmailCom;
|
||||
use bkrukowski\TransparentEmail\Services\MailRu;
|
||||
use bkrukowski\TransparentEmail\Services\IcloudCom;
|
||||
use bkrukowski\TransparentEmail\Services\OutlookCom;
|
||||
use bkrukowski\TransparentEmail\Services\TlenPl;
|
||||
use bkrukowski\TransparentEmail\Services\Www33MailCom;
|
||||
@ -41,7 +42,8 @@ class TransparentEmailFactory
|
||||
TlenPl::class,
|
||||
AppsGoogleCom::class,
|
||||
MailRu::class,
|
||||
YandexRu::class
|
||||
YandexRu::class,
|
||||
IcloudCom::class
|
||||
];
|
||||
}
|
||||
}
|
||||
|
49
tests/Services/IcloudComTest.php
Normal file
49
tests/Services/IcloudComTest.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\TransparentEmail\Tests\Services;
|
||||
|
||||
use bkrukowski\TransparentEmail\Emails\Email;
|
||||
use bkrukowski\TransparentEmail\Services\IcloudCom;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class IcloudComTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerGetPrimaryEmail
|
||||
*
|
||||
* @param string $inputEmail
|
||||
* @param string $outputEmail
|
||||
*/
|
||||
public function testGetPrimaryEmail(string $inputEmail, string $outputEmail)
|
||||
{
|
||||
$this->assertEquals($outputEmail, (new IcloudCom())->getPrimaryEmail(new Email($inputEmail)));
|
||||
}
|
||||
|
||||
public function providerGetPrimaryEmail() : array
|
||||
{
|
||||
return [
|
||||
['foobar@ICLOUD.COM', 'foobar@icloud.com'],
|
||||
['foobar+alias@icloud.com', 'foobar@icloud.com'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIsSupported
|
||||
*
|
||||
* @param string $domain
|
||||
* @param bool $result
|
||||
*/
|
||||
public function testIsSupported(string $domain, bool $result)
|
||||
{
|
||||
$this->assertSame($result, (new IcloudCom())->isSupported(new Email('Jane.Doe@' . $domain)));
|
||||
}
|
||||
|
||||
public function providerIsSupported() : array
|
||||
{
|
||||
return [
|
||||
['icloud.com', true],
|
||||
['ICLOUD.COM', true],
|
||||
['i.cloud.com', false],
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user