承接 componenta/email 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

componenta/email

Composer 安装命令:

composer require componenta/email

包简介

Email value object

README 文档

README

Immutable email address value object with validation, normalization, masking, domain helpers, and JSON/string serialization.

Use it at application boundaries where a validated email address should be represented as a typed value instead of a raw string.

Installation

composer require componenta/email

Requires the mbstring extension.

Related Packages

This package validates email values without neighboring Componenta packages.

Package Why it may be used nearby
componenta/validation Validates user input before creating Email.
componenta/auth Can use email for login, password reset, or magic-link flows.
componenta/cqrs Commands can type email fields with this value object.

Usage

use Componenta\Stdlib\Email;

$email = Email::fromString('Ada@Example.COM');

(string) $email;        // "ada@example.com"
$email->local;          // "ada"
$email->domain;         // "example.com"
$email->isFromDomain('example.com'); // true
$email->masked();       // "ad*@example.com"

Validation

new Email() and Email::fromString() throw InvalidArgumentException when:

  • the address is empty
  • the address is not accepted by FILTER_VALIDATE_EMAIL
  • the full address exceeds 254 characters
  • the local part exceeds 64 characters
  • the domain exceeds 253 characters

Use Email::tryFromString() when invalid input should produce null.

Normalization

The constructor trims whitespace, removes invisible control characters, and lowercases both local and domain parts. The stored value, __toString(), and jsonSerialize() all return the normalized address.

Helpers

  • equals() compares normalized addresses
  • tld() returns the last domain segment
  • isFromDomain() performs case-insensitive domain comparison
  • masked() returns a log/UI-safe representation

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固