mirror of
https://github.com/retailcrm/transparent-email.git
synced 2024-11-21 21:06:04 +03:00
Rename to TransparentEmail
This commit is contained in:
parent
cbaf122289
commit
6011268049
@ -2,9 +2,9 @@
|
||||
[![Coverage Status](https://coveralls.io/repos/github/bkrukowski/gordianus/badge.svg?branch=master)](https://coveralls.io/github/bkrukowski/gordianus?branch=master)
|
||||
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/b057fa037a3b4f318f75af27b0b01d47)](https://www.codacy.com/app/bartlomiej-krukowski/gordianus?utm_source=github.com&utm_medium=referral&utm_content=bkrukowski/gordianus&utm_campaign=Badge_Grade)
|
||||
|
||||
# Gordianus
|
||||
# Transparent Email
|
||||
|
||||
Gordianus clears aliases from email address. Email `John.Doe+alias@gmail.com` will be transformed to `johndoe@gmail.com`.
|
||||
Transparent Email clears aliases from email address. Email `John.Doe+alias@gmail.com` will be transformed to `johndoe@gmail.com`.
|
||||
|
||||
## Why?
|
||||
|
||||
@ -21,8 +21,8 @@ To detect multi-accounts on your website.
|
||||
## Usage
|
||||
|
||||
```php
|
||||
$gordianus = new \bkrukowski\Gordianus\Gordianus();
|
||||
$transformedEmail = $gordianus->getPrimaryEmail('John.Doe+alias@gmail.com');
|
||||
$cleaner = new \bkrukowski\TransparentEmail\TransparentEmail();
|
||||
$transformedEmail = $cleaner->getPrimaryEmail('John.Doe+alias@gmail.com');
|
||||
```
|
||||
|
||||
## Yahoo.com
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "bkrukowski/gordianus",
|
||||
"name": "bkrukowski/transparent-email",
|
||||
"description": "Remove aliases from email and get primary email account",
|
||||
"type": "library",
|
||||
"require": {
|
||||
@ -19,12 +19,12 @@
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"bkrukowski\\Gordianus\\": "src/"
|
||||
"bkrukowski\\TransparentEmail\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"bkrukowski\\Gordianus\\Tests\\": "tests/"
|
||||
"bkrukowski\\TransparentEmail\\Tests\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Gordianus Test Suite">
|
||||
<testsuite name="TransparentEmail Test Suite">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\Gordianus;
|
||||
namespace bkrukowski\TransparentEmail;
|
||||
|
||||
class InvalidEmailException extends \Exception
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\Gordianus\Services;
|
||||
namespace bkrukowski\TransparentEmail\Services;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\Gordianus\Services;
|
||||
namespace bkrukowski\TransparentEmail\Services;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\Gordianus\Services;
|
||||
namespace bkrukowski\TransparentEmail\Services;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\Gordianus\Services;
|
||||
namespace bkrukowski\TransparentEmail\Services;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\Gordianus\Services;
|
||||
namespace bkrukowski\TransparentEmail\Services;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\Gordianus\Services;
|
||||
namespace bkrukowski\TransparentEmail\Services;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\Gordianus\Services;
|
||||
namespace bkrukowski\TransparentEmail\Services;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\Gordianus;
|
||||
namespace bkrukowski\TransparentEmail;
|
||||
|
||||
use bkrukowski\Gordianus\Services\GmailCom;
|
||||
use bkrukowski\Gordianus\Services\OutlookCom;
|
||||
use bkrukowski\Gordianus\Services\ServiceInterface;
|
||||
use bkrukowski\Gordianus\Services\TlenPl;
|
||||
use bkrukowski\Gordianus\Services\Www33MailCom;
|
||||
use bkrukowski\Gordianus\Services\YahooCom;
|
||||
use bkrukowski\TransparentEmail\Services\GmailCom;
|
||||
use bkrukowski\TransparentEmail\Services\OutlookCom;
|
||||
use bkrukowski\TransparentEmail\Services\ServiceInterface;
|
||||
use bkrukowski\TransparentEmail\Services\TlenPl;
|
||||
use bkrukowski\TransparentEmail\Services\Www33MailCom;
|
||||
use bkrukowski\TransparentEmail\Services\YahooCom;
|
||||
|
||||
class Gordianus
|
||||
class TransparentEmail
|
||||
{
|
||||
const SERVICE_GMAIL_COM = GmailCom::class;
|
||||
const SERVICE_TLEN_PL = TlenPl::class;
|
@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\Gordianus\Tests;
|
||||
|
||||
use bkrukowski\Gordianus\Gordianus;
|
||||
use bkrukowski\Gordianus\InvalidEmailException;
|
||||
|
||||
class GordianusTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerValidator
|
||||
*
|
||||
* @param string $email
|
||||
* @param bool $validEmail
|
||||
*/
|
||||
public function testValidator(string $email, bool $validEmail)
|
||||
{
|
||||
if (!$validEmail) {
|
||||
$this->expectException(InvalidEmailException::class);
|
||||
}
|
||||
(new Gordianus())->getPrimaryEmail($email);
|
||||
}
|
||||
|
||||
public function providerValidator()
|
||||
{
|
||||
return [
|
||||
['john.doe@gmail.comm', true],
|
||||
['john doe@gmail.com', false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerGetPrimaryEmail
|
||||
*
|
||||
* @param Gordianus $gordianus
|
||||
* @param string $email
|
||||
* @param string $expectedEmail
|
||||
*/
|
||||
public function testGetPrimaryEmail(Gordianus $gordianus, string $email, string $expectedEmail)
|
||||
{
|
||||
$this->assertSame($expectedEmail, $gordianus->getPrimaryEmail($email));
|
||||
}
|
||||
|
||||
public function providerGetPrimaryEmail()
|
||||
{
|
||||
return [
|
||||
[new Gordianus([Gordianus::SERVICE_TLEN_PL]), 'john.doe+alias@gmail.com', 'john.doe+alias@gmail.com'],
|
||||
[new Gordianus(), 'john.doe+alias@gmail.com', 'johndoe@gmail.com'],
|
||||
[new Gordianus([]), 'John.Doe@example.com', 'john.doe@example.com'],
|
||||
[new Gordianus([], true), 'John.Doe@example.com', 'John.Doe@example.com'],
|
||||
[new Gordianus(Gordianus::ALL_SERVICES, true), 'John.Doe@gmail.com', 'johndoe@gmail.com'],
|
||||
[new Gordianus(), 'Jane.Doe+receipts@hotmail.com', 'jane.doe@hotmail.com'],
|
||||
[new Gordianus(), 'Jane.Doe-receipts@yahoo.com', 'jane.doe@yahoo.com'],
|
||||
];
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\Gordianus\Tests\Services;
|
||||
namespace bkrukowski\TransparentEmail\Tests\Services;
|
||||
|
||||
use bkrukowski\Gordianus\Services\GmailCom;
|
||||
use bkrukowski\TransparentEmail\Services\GmailCom;
|
||||
|
||||
class GmailComTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\Gordianus\Tests\Services;
|
||||
namespace bkrukowski\TransparentEmail\Tests\Services;
|
||||
|
||||
use bkrukowski\Gordianus\Services\MultiDomain;
|
||||
use bkrukowski\TransparentEmail\Services\MultiDomain;
|
||||
|
||||
class MultiDomainTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\Gordianus\Tests\Services;
|
||||
namespace bkrukowski\TransparentEmail\Tests\Services;
|
||||
|
||||
use bkrukowski\Gordianus\Services\OutlookCom;
|
||||
use bkrukowski\TransparentEmail\Services\OutlookCom;
|
||||
|
||||
class OutlookComTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\Gordianus\Tests\Services;
|
||||
namespace bkrukowski\TransparentEmail\Tests\Services;
|
||||
|
||||
use bkrukowski\Gordianus\Services\Www33MailCom;
|
||||
use bkrukowski\TransparentEmail\Services\Www33MailCom;
|
||||
|
||||
class Www33MailComTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\Gordianus\Tests\Services;
|
||||
namespace bkrukowski\TransparentEmail\Tests\Services;
|
||||
|
||||
use bkrukowski\Gordianus\Services\YahooCom;
|
||||
use bkrukowski\TransparentEmail\Services\YahooCom;
|
||||
|
||||
class YahooComTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
56
tests/TransparentEmailTest.php
Normal file
56
tests/TransparentEmailTest.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace bkrukowski\TransparentEmail\Tests;
|
||||
|
||||
use bkrukowski\TransparentEmail\TransparentEmail;
|
||||
use bkrukowski\TransparentEmail\InvalidEmailException;
|
||||
|
||||
class TransparentEmailTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerValidator
|
||||
*
|
||||
* @param string $email
|
||||
* @param bool $validEmail
|
||||
*/
|
||||
public function testValidator(string $email, bool $validEmail)
|
||||
{
|
||||
if (!$validEmail) {
|
||||
$this->expectException(InvalidEmailException::class);
|
||||
}
|
||||
(new TransparentEmail())->getPrimaryEmail($email);
|
||||
}
|
||||
|
||||
public function providerValidator()
|
||||
{
|
||||
return [
|
||||
['john.doe@gmail.comm', true],
|
||||
['john doe@gmail.com', false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerGetPrimaryEmail
|
||||
*
|
||||
* @param TransparentEmail $TransparentEmail
|
||||
* @param string $email
|
||||
* @param string $expectedEmail
|
||||
*/
|
||||
public function testGetPrimaryEmail(TransparentEmail $TransparentEmail, string $email, string $expectedEmail)
|
||||
{
|
||||
$this->assertSame($expectedEmail, $TransparentEmail->getPrimaryEmail($email));
|
||||
}
|
||||
|
||||
public function providerGetPrimaryEmail()
|
||||
{
|
||||
return [
|
||||
[new TransparentEmail([TransparentEmail::SERVICE_TLEN_PL]), 'john.doe+alias@gmail.com', 'john.doe+alias@gmail.com'],
|
||||
[new TransparentEmail(), 'john.doe+alias@gmail.com', 'johndoe@gmail.com'],
|
||||
[new TransparentEmail([]), 'John.Doe@example.com', 'john.doe@example.com'],
|
||||
[new TransparentEmail([], true), 'John.Doe@example.com', 'John.Doe@example.com'],
|
||||
[new TransparentEmail(TransparentEmail::ALL_SERVICES, true), 'John.Doe@gmail.com', 'johndoe@gmail.com'],
|
||||
[new TransparentEmail(), 'Jane.Doe+receipts@hotmail.com', 'jane.doe@hotmail.com'],
|
||||
[new TransparentEmail(), 'Jane.Doe-receipts@yahoo.com', 'jane.doe@yahoo.com'],
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user