2017 © Pedro Peláez
 

library email-address

Email address value object.

image

nepada/email-address

Email address value object.

  • Monday, July 9, 2018
  • by xificurk
  • Repository
  • 1 Watchers
  • 1 Stars
  • 400 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Email address value object

Build Status Coverage Status Downloads this Month Latest stable, (*1)

Installation

Via Composer:, (*2)

$ composer require nepada/email-address

Usage

This package provides two implementations of email address value object: 1) RfcEmailAddress - it adheres to RFCs and treats local part of email address as case sensitive. The domain part is normalized to lower case ASCII representation. 2) CaseInsensitiveEmailAddress - the only difference from RfcEmailAddress is that local part is considered case insensitive and normalized to lower case., (*3)

It is up to you to decide which implementation suites your needs. If you want to support both implementations, use Nepada\EmailAddress\EmailAddress as a typehint. You can also cast one representation to the other using RfcEmailAddress::toCaseInsensitiveEmailAddress() and CaseInsensitiveEmailAddress::toRfcEmailAddress()., (*4)

Creating value object

$rfcEmailAddress = Nepada\EmailAddress\RfcEmailAddress::fromString('Real.example+suffix@HÁČKYčárky.cz');
$rfcEmailAddress = Nepada\EmailAddress\RfcEmailAddress::fromDomainAndLocalPart('HÁČKYčárky.cz', 'Real.example+suffix');

$ciEmailAddress = Nepada\EmailAddress\CaseInsensitiveEmailAddress::fromString('Real.example+suffix@HÁČKYčárky.cz');
$ciEmailAddress = Nepada\EmailAddress\CaseInsensitiveEmailAddress::fromDomainAndLocalPart('HÁČKYčárky.cz', 'Real.example+suffix');

Nepada\EmailAddress\InvalidEmailAddressException is thrown in case of invalid input value., (*5)

Converting back to string

Casting the value object to string, will result in the original (non-canonical) string representation of email address:, (*6)

echo((string) $emailAddress); // Real.example+suffix@HÁČKYčárky.cz
echo($emailAddress->toString()); // Real.example+suffix@HÁČKYčárky.cz

Canonical string representation of email address

echo($emailAddress->getValue()); // real.example+suffix@xn--hkyrky-ptac70bc.cz

Getting normalized local and domain part separately

echo($emailAddress->getLocalPart()); // real.example+suffix
echo($emailAddress->getDomain()); // xn--hkyrky-ptac70bc.cz

Integrations

The Versions

09/07 2018

dev-master

9999999-dev

Email address value object.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Petr Morávek

nette value object email address

09/07 2018

v1.1.0

1.1.0.0

Email address value object.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Petr Morávek

nette value object email address

02/06 2018

v1.0.0

1.0.0.0

Email address value object.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Petr Morávek

nette value object email address