Add Yandex.ru replacement dots for dashes

This commit is contained in:
gridnev 2020-02-17 11:13:11 +03:00
parent 2b41d9fe15
commit ed8a560b00
3 changed files with 10 additions and 0 deletions

View File

@ -25,6 +25,14 @@ class EditableEmail implements EmailInterface
return $copy; 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 public function removeSuffixAlias(string $delimiter) : EditableEmail
{ {
$copy = clone $this; $copy = clone $this;

View File

@ -13,6 +13,7 @@ class YandexRu implements ServiceInterface
{ {
return (new EditableEmail($email)) return (new EditableEmail($email))
->removeSuffixAlias('+') ->removeSuffixAlias('+')
->replaceInLocalPart('.', '-')
->lowerCaseLocalPartIf(true) ->lowerCaseLocalPartIf(true)
->setDomain($this->mapDomain($email->getDomain())); ->setDomain($this->mapDomain($email->getDomain()));
} }

View File

@ -28,6 +28,7 @@ class YandexRuTest extends TestCase
['fOObar@YAndEX.ru', 'foobar@yandex.ru'], ['fOObar@YAndEX.ru', 'foobar@yandex.ru'],
['foobar+alias@yandex.ru', 'foobar@yandex.ru'], ['foobar+alias@yandex.ru', 'foobar@yandex.ru'],
['JaneDoe@ya.ru', 'janedoe@yandex.ru'], ['JaneDoe@ya.ru', 'janedoe@yandex.ru'],
['Jane.Doe@ya.ru', 'jane-doe@yandex.ru'],
]; ];
} }