From 50e1da498efeba80d26971190647a5158a81c497 Mon Sep 17 00:00:00 2001 From: gridnev Date: Tue, 18 Feb 2020 16:56:53 +0300 Subject: [PATCH] add ICloud Service --- README.md | 11 +++---- src/Services/IcloudCom.php | 21 +++++++++++++ src/Services/MailRu.php | 19 ++---------- src/Services/OutlookCom.php | 2 +- src/TransparentEmailFactory.php | 2 ++ tests/Services/IcloudComTest.php | 49 +++++++++++++++++++++++++++++++ tests/Services/MailRuTest.php | 6 ---- tests/Services/OutlookComTest.php | 6 ++++ tests/TransparentEmailTest.php | 3 ++ 9 files changed, 90 insertions(+), 29 deletions(-) create mode 100644 src/Services/IcloudCom.php create mode 100644 tests/Services/IcloudComTest.php diff --git a/README.md b/README.md index 937d409..a836e62 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ To detect multi-accounts on your website. * [33mail.com](https://www.33mail.com) * [outlook.com](http://outlook.com) * [yahoo.com](http://mail.yahoo.com) +* [icloud.com](https://www.icloud.com/) * [yandex.ru](https://yandex.ru/) * [mail.ru](https://mail.ru/) @@ -63,11 +64,11 @@ which actually does not exist. In official [documentation](https://yandex.com/support/mail/web/preferences/about-sender/additional-addresses.html) you can find some use-cases about aliases usage. ## Mail.ru -There's no official documentation about aliases here, but you can create them with these ways: +Mail.ru service uses following aliases: * `janedoe+alias@mail.ru` will be redirected to `janedoe@mail.ru` * `janeDoe@MAIL.RU` will be redirected to `janedoe@mail.ru` -Also, it's possible to create aliases in the settings of Mail.ru, for example, like these ones: -* `janeDoe@list.ru` will be redirected to `janedoe@mail.ru` -* `janeDoe@inbox.ru` will be redirected to `janedoe@mail.ru` -* `janeDoe@bk.ru` will be redirected to `janedoe@mail.ru` +## Icloud.com +Icloud.com service uses following aliases: +* `janedoe+alias@icloud.com` will be redirected to `janedoe@icloud.com` +* `janeDoe@ICLOUD.COM` will be redirected to `janedoe@icloud.com` \ No newline at end of file diff --git a/src/Services/IcloudCom.php b/src/Services/IcloudCom.php new file mode 100644 index 0000000..55f575d --- /dev/null +++ b/src/Services/IcloudCom.php @@ -0,0 +1,21 @@ +removeSuffixAlias('+') + ->lowerCaseLocalPartIf(true); + } + + public function isSupported(EmailInterface $email) : bool + { + return in_array($email->getDomain(), ['icloud.com']); + } +} \ No newline at end of file diff --git a/src/Services/MailRu.php b/src/Services/MailRu.php index 5d9233e..26950ed 100644 --- a/src/Services/MailRu.php +++ b/src/Services/MailRu.php @@ -13,26 +13,11 @@ class MailRu implements ServiceInterface { return (new EditableEmail($email)) ->removeSuffixAlias('+') - ->lowerCaseLocalPartIf(true) - ->setDomain($this->mapDomain($email->getDomain())); + ->lowerCaseLocalPartIf(true); } public function isSupported(EmailInterface $email) : bool { - return in_array($email->getDomain(), ['mail.ru', 'list.ru', 'inbox.ru', 'bk.ru']); - } - - protected function getDomainMapping() : array - { - return [ - 'list.ru' => 'mail.ru', - 'inbox.ru' => 'mail.ru', - 'bk.ru' => 'mail.ru', - ]; - } - - private function mapDomain(string $domain) : string - { - return $this->getDomainMapping()[$domain] ?? $domain; + return in_array($email->getDomain(), ['mail.ru']); } } \ No newline at end of file diff --git a/src/Services/OutlookCom.php b/src/Services/OutlookCom.php index 32e6ea2..b4021cf 100644 --- a/src/Services/OutlookCom.php +++ b/src/Services/OutlookCom.php @@ -18,6 +18,6 @@ class OutlookCom implements ServiceInterface public function isSupported(EmailInterface $email) : bool { - return in_array($email->getDomain(), ['outlook.com', 'hotmail.com'], true); + return in_array($email->getDomain(), ['outlook.com', 'hotmail.com', 'live.com', 'msn.com'], true); } } \ No newline at end of file diff --git a/src/TransparentEmailFactory.php b/src/TransparentEmailFactory.php index 932455a..9b8a917 100644 --- a/src/TransparentEmailFactory.php +++ b/src/TransparentEmailFactory.php @@ -6,6 +6,7 @@ namespace bkrukowski\TransparentEmail; use bkrukowski\TransparentEmail\Services\AppsGoogleCom; use bkrukowski\TransparentEmail\Services\GmailCom; +use bkrukowski\TransparentEmail\Services\IcloudCom; use bkrukowski\TransparentEmail\Services\MailRu; use bkrukowski\TransparentEmail\Services\OutlookCom; use bkrukowski\TransparentEmail\Services\TlenPl; @@ -42,6 +43,7 @@ class TransparentEmailFactory AppsGoogleCom::class, YandexRu::class, MailRu::class, + IcloudCom::class ]; } } \ No newline at end of file diff --git a/tests/Services/IcloudComTest.php b/tests/Services/IcloudComTest.php new file mode 100644 index 0000000..f89ebde --- /dev/null +++ b/tests/Services/IcloudComTest.php @@ -0,0 +1,49 @@ +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], + ]; + } +} \ No newline at end of file diff --git a/tests/Services/MailRuTest.php b/tests/Services/MailRuTest.php index fb7252a..13dd81c 100644 --- a/tests/Services/MailRuTest.php +++ b/tests/Services/MailRuTest.php @@ -27,9 +27,6 @@ class MailRuTest extends TestCase ['foobar@MAIL.RU', 'foobar@mail.ru'], ['fOObar@MaiL.Ru', 'foobar@mail.ru'], ['foobar+alias@mail.ru', 'foobar@mail.ru'], - ['foobar@list.ru', 'foobar@mail.ru'], - ['foobar@inbox.ru', 'foobar@mail.ru'], - ['foobar@bk.ru', 'foobar@mail.ru'], ]; } @@ -48,9 +45,6 @@ class MailRuTest extends TestCase { return [ ['mail.ru', true], - ['list.ru', true], - ['inbox.ru', true], - ['bk.ru', true], ['mail.RU', true], ['MAIL.RU', true], ['ma.il.ru', false], diff --git a/tests/Services/OutlookComTest.php b/tests/Services/OutlookComTest.php index d4f715c..5d7ceeb 100644 --- a/tests/Services/OutlookComTest.php +++ b/tests/Services/OutlookComTest.php @@ -27,7 +27,11 @@ class OutlookComTest extends TestCase ['outlook.com', true], ['Outlook.Com', true], ['hotmail.com', true], + ['msn.com', true], + ['live.com', true], ['HotMail.COM', true], + ['Msn.COM', true], + ['LIve.COM', true], ['gmail.com', false], ['tlen.pl', false], ]; @@ -52,6 +56,8 @@ class OutlookComTest extends TestCase ['Jane.Doe@Outlook.Com', 'jane.doe@outlook.com'], ['Jane.Doe+alias@OUTLOOK.COM', 'jane.doe@outlook.com'], ['Jane.Doe+Hotmail@hotmail.com', 'jane.doe@hotmail.com'], + ['Jane.Doe+Hotmail@live.com', 'jane.doe@live.com'], + ['Jane.Doe+Hotmail@msn.com', 'jane.doe@msn.com'], ]; } } \ No newline at end of file diff --git a/tests/TransparentEmailTest.php b/tests/TransparentEmailTest.php index e12b24b..83d3aa4 100644 --- a/tests/TransparentEmailTest.php +++ b/tests/TransparentEmailTest.php @@ -48,6 +48,9 @@ class TransparentEmailTest extends TestCase [new TransparentEmail($emptyServiceCollector), 'John.Doe@example.com', 'John.Doe@example.com', true], [(new TransparentEmailFactory())->createDefault(), 'John.Doe@gmail.com', 'johndoe@gmail.com', true], [(new TransparentEmailFactory())->createDefault(), 'Jane.Doe+receipts@hotmail.com', 'jane.doe@hotmail.com'], + [(new TransparentEmailFactory())->createDefault(), 'Jane.Doe+receipts@live.com', 'jane.doe@live.com'], + [(new TransparentEmailFactory())->createDefault(), 'Jane.Doe+receipts@msn.com', 'jane.doe@msn.com'], + [(new TransparentEmailFactory())->createDefault(), 'Jane.Doe+receipts@outlook.com', 'jane.doe@outlook.com'], [(new TransparentEmailFactory())->createDefault(), 'Jane.Doe-receipts@yahoo.com', 'jane.doe@yahoo.com'], ]; }