Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmichot committed Feb 4, 2014
0 parents commit fd16d2b
Show file tree
Hide file tree
Showing 16 changed files with 779 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.travis.yml export-ignore
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
composer.lock
composer.phar
vendor
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/Uuid62.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/scopes/scope_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

310 changes: 310 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2013 Lucas Michot [[email protected]] and other contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
284 changes: 284 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
# Unaliaser

A PHP library to track, de-duplicate and un-alias Google Mail and Google Apps emails.

[![Latest Stable Version](https://poser.pugx.org/lucasmichot/unaliaser/v/stable.png)](https://packagist.org/packages/lucasmichot/unaliaser)
[![Total Downloads](https://poser.pugx.org/lucasmichot/unaliaser/downloads.png)](https://packagist.org/packages/lucasmichot/unaliaser)
[![Build Status](https://travis-ci.org/lucasmichot/unaliaser.png)](https://travis-ci.org/lucasmichot/unaliaser)

* [Requiring/Loading](#requiringloading)
* [Methods](#methods)
* [__construct()](#__construct)
* [cleanEmail()](#cleanEmail)
* [domainName()](#domainName)
* [isGmail()](#isGmail)
* [isGoogleApps()](#isGoogleApps)
* [isGoogle()](#isGoogle)
* [uniqueDomainName()](#uniqueDomainName)
* [userName()](#userName)
* [userAlias()](#userAlias)
* [hasUserAlias()](#hasUserAlias)
* [userOrigin()](#userOrigin)
* [userUndottedOrigin()](#userUndottedOrigin)
* [unique()](#unique)
* [userIsDotted()](#userIsDotted)
* [isUnique()](#isUnique)
* [Tests](#tests)
* [License](#license)

## Requiring / Loading

If you're using Composer to manage dependencies, you can include the following
in your `composer.json` file:

"require": {
"unaliaser/unaliaser": "dev-master"
}

Then, after running `composer update` or `php composer.phar update`, you can
load the class using Composer's autoloading:

```php
require 'vendor/autoload.php';
```

Otherwise, you can simply require the file directly:

```php
require_once 'path/to/Unaliaser/src/Unaliaser/Unaliaser.php';
```

## Methods

#### __construct()

Creates a new instance of `Unaliaser`.

```php
$unaliaser = new Unaliaser('[email protected]');
```

**If the email is not valid, an `InvalidArgumentExcpetion` will be thrown.**

#### cleanEmail()

Returns a clean email.

```php
$unaliaser = new Unaliaser(' [email protected] ');
echo $unaliaser->cleanEmail();
// '[email protected]'
```

#### domainName()

Returns a the domain name for the email.

```php
$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->domainName();
// 'bar.com'
```

#### isGmail()

Check if an email is managed by Google Mail.

```php
$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isGmail();
// true

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isGmail();
// false
```

#### isGoogleApps()

Check if an email is managed by Google Apps.

```php
$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isGoogleApps();
// false

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isGoogleApps();
// false

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isGoogleApps();
// true
```

#### isGoogle()

Check if an email is managed by Google (Gmail or Google Apps).

```php
$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isGoogle();
// true

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isGoogle();
// false

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isGoogle();
// true
```

#### uniqueDomainName()

Get the unique domain name for a Gmail address.

```php
$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->uniqueDomainName();
// 'gmail.com'

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->uniqueDomainName();
// 'googlemail.com'

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->uniqueDomainName();
// 'yahoo.com'
```

#### mxRecords()

Get the MX records for the domain name of an email address.

```php
$unaliaser = new Unaliaser('[email protected]');
print_r($unaliaser->mxRecords());
// display an array containing various MX records for the domain of this email address
```

#### userName()

Get the username for an email address.

```php
$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userName();
// 'johndoe'
```

#### userAlias()

Get the user alias for a Google address, if any.

```php
$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userAlias();
// 'dummyalias'

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userAlias();
// null
```

#### hasUserAlias()

Determines if a Google email address contains an user alias.

```php
$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->hasUserAlias();
// false

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->hasUserAlias();
// true
```

#### userOrigin()

Get the original username for a email.

```php
$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userOrigin();
// 'johndoe+alias'

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userOrigin();
// 'johndoe'
```

#### userUndottedOrigin()

Get the original un-dotted username for a Google address.

```php
$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userUndottedOrigin();
// 'john.doe'

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userUndottedOrigin();
// 'johndoe'
```


#### userIsDotted()

Determines if a Google address is dotted.

```php
$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userIsDotted();
// false

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->userIsDotted();
// true
```

#### unique()

Get the unique email address.

```php
$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->unique();
// '[email protected]'

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->unique();
// '[email protected]'
```

#### isUnique()

Determines if the provided email is unique (dotted or aliased).

```php
$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isUnique();
// true

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isUnique();
// false

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isUnique();
// false

$unaliaser = new Unaliaser('[email protected]');
echo $unaliaser->isUnique();
// true
```

## Tests

From the project directory, tests can be ran using `phpunit`

## License

Released under the MIT License - see `LICENSE.txt` for details.
31 changes: 31 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "lucasmichot/uuid62",
"type": "library",
"description": "generate a unique Uuid from a value, using base 62.",
"keywords": [
"uuid",
"base",
"62",
"identifier"
],
"homepage": "https://github.com/lucasmichot/uuid62",
"authors": [
{
"name": "Lucas Michot",
"email": "[email protected]",
"homepage": "http://semalead.com"
}
],
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"autoload": {
"psr-0": {
"Uuid62": "src"
}
},
"license": "MIT"
}
Loading

0 comments on commit fd16d2b

Please sign in to comment.