From ed8a560b00a42019c52c717cb6241f0dfb90185e Mon Sep 17 00:00:00 2001 From: gridnev Date: Mon, 17 Feb 2020 11:13:11 +0300 Subject: [PATCH] Add Yandex.ru replacement dots for dashes --- src/Emails/EditableEmail.php | 8 ++++++++ src/Services/YandexRu.php | 1 + tests/Services/YandexRuTest.php | 1 + 3 files changed, 10 insertions(+) diff --git a/src/Emails/EditableEmail.php b/src/Emails/EditableEmail.php index cb223bd..e013cdd 100644 --- a/src/Emails/EditableEmail.php +++ b/src/Emails/EditableEmail.php @@ -25,6 +25,14 @@ class EditableEmail implements EmailInterface return $copy; } + public function replaceInLocalPart(string $toReplace, string $replacement) : EditableEmail + { + $copy = clone $this; + $copy->localPart = str_replace($toReplace, $replacement, $this->localPart); + + return $copy; + } + public function removeSuffixAlias(string $delimiter) : EditableEmail { $copy = clone $this; diff --git a/src/Services/YandexRu.php b/src/Services/YandexRu.php index 20ffcf3..b883cab 100644 --- a/src/Services/YandexRu.php +++ b/src/Services/YandexRu.php @@ -13,6 +13,7 @@ class YandexRu implements ServiceInterface { return (new EditableEmail($email)) ->removeSuffixAlias('+') + ->replaceInLocalPart('.', '-') ->lowerCaseLocalPartIf(true) ->setDomain($this->mapDomain($email->getDomain())); } diff --git a/tests/Services/YandexRuTest.php b/tests/Services/YandexRuTest.php index e41b495..1dadce0 100644 --- a/tests/Services/YandexRuTest.php +++ b/tests/Services/YandexRuTest.php @@ -28,6 +28,7 @@ class YandexRuTest extends TestCase ['fOObar@YAndEX.ru', 'foobar@yandex.ru'], ['foobar+alias@yandex.ru', 'foobar@yandex.ru'], ['JaneDoe@ya.ru', 'janedoe@yandex.ru'], + ['Jane.Doe@ya.ru', 'jane-doe@yandex.ru'], ]; }