diff --git a/src/Services/AppsGoogleCom.php b/src/Services/AppsGoogleCom.php new file mode 100644 index 0000000..4fbc6a4 --- /dev/null +++ b/src/Services/AppsGoogleCom.php @@ -0,0 +1,23 @@ +mapDomain($domain); } public function isDomainSupported(string $domain) : bool { return in_array(strtolower($domain), ['gmail.com', 'googlemail.com']); } + + private function mapDomain(string $domain) : string + { + $mapping = [ + 'googlemail.com' => 'gmail.com', + ]; + return $mapping[$domain] ?? $domain; + } } \ No newline at end of file diff --git a/src/TransparentEmail.php b/src/TransparentEmail.php index d88fab9..feed823 100644 --- a/src/TransparentEmail.php +++ b/src/TransparentEmail.php @@ -2,6 +2,7 @@ namespace bkrukowski\TransparentEmail; +use bkrukowski\TransparentEmail\Services\AppsGoogleCom; use bkrukowski\TransparentEmail\Services\GmailCom; use bkrukowski\TransparentEmail\Services\OutlookCom; use bkrukowski\TransparentEmail\Services\ServiceInterface; @@ -16,6 +17,7 @@ class TransparentEmail const SERVICE_WWW_33MAIL_COM = Www33MailCom::class; const SERVICE_OUTLOOK_COM = OutlookCom::class; const SERVICE_YAHOO_COM = YahooCom::class; + const SERVICE_APPS_GOOGLE_COM = AppsGoogleCom::class; /** * Constant ALL_SERVICES can contain different values depends on API version @@ -26,6 +28,7 @@ class TransparentEmail self::SERVICE_WWW_33MAIL_COM, self::SERVICE_OUTLOOK_COM, self::SERVICE_YAHOO_COM, + self::SERVICE_APPS_GOOGLE_COM, ]; private $services; diff --git a/tests/Services/AppsGoogleComTest.php b/tests/Services/AppsGoogleComTest.php new file mode 100644 index 0000000..28c2d35 --- /dev/null +++ b/tests/Services/AppsGoogleComTest.php @@ -0,0 +1,27 @@ +assertSame($result, (new AppsGoogleCom())->isDomainSupported($domain)); + } + + public function providerIsDomainSupported() + { + return [ + ['example.com', false], + ['krukowski.me', true], + ]; + } +} \ No newline at end of file diff --git a/tests/Services/GmailComTest.php b/tests/Services/GmailComTest.php index bed265a..84a27e2 100644 --- a/tests/Services/GmailComTest.php +++ b/tests/Services/GmailComTest.php @@ -24,7 +24,7 @@ class GmailComTest extends \PHPUnit_Framework_TestCase ['Foo.Bar@GMAIL.COM', 'foobar@gmail.com'], ['foobar+alias@gmail.com', 'foobar@gmail.com'], ['fo.ob.ar+alias@gmail.com', 'foobar@gmail.com'], - ['JaneDoe@googlemail.com', 'janedoe@googlemail.com'], + ['JaneDoe@googlemail.com', 'janedoe@gmail.com'], ]; }