nepada/email-address
最新稳定版本:v3.3.1
Composer 安装命令:
composer require nepada/email-address
包简介
Email address value object.
README 文档
README
Installation
Via Composer:
$ composer require nepada/email-address
Usage
This package provides two implementations of email address value object:
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.CaseInsensitiveEmailAddress- the only difference fromRfcEmailAddressis that local part is considered case insensitive and normalized to lower case.
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().
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.
Converting back to string
Casting the value object to string, will result in the original (non-canonical) string representation of email address:
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
- nepada/email-address-doctrine - Email address type for Doctrine.
- nepada/email-address-input - Email address form input for Nette forms.
统计信息
- 总下载量: 43.15k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 1
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2018-06-02