From 2e4cd9ff470fb7b2d4aaa4020ec5139c68f88da1 Mon Sep 17 00:00:00 2001 From: gridnev Date: Wed, 19 Feb 2020 12:34:15 +0300 Subject: [PATCH] Add Icloud.com service support --- src/Services/IcloudCom.php | 21 ++++++++++++++ src/TransparentEmailFactory.php | 4 ++- tests/Services/IcloudComTest.php | 49 ++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 src/Services/IcloudCom.php create mode 100644 tests/Services/IcloudComTest.php 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/TransparentEmailFactory.php b/src/TransparentEmailFactory.php index 34e68f5..24c9930 100644 --- a/src/TransparentEmailFactory.php +++ b/src/TransparentEmailFactory.php @@ -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 ]; } } 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