PHPackages                             effectra/email-address-formatter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. effectra/email-address-formatter

ActiveLibrary

effectra/email-address-formatter
================================

The Effectra Email Address Formatter package.

v1.0.1(7mo ago)041MITPHP

Since Oct 3Pushed 7mo agoCompare

[ Source](https://github.com/effectra/email-address-formatter)[ Packagist](https://packagist.org/packages/effectra/email-address-formatter)[ RSS](/packages/effectra-email-address-formatter/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)DependenciesVersions (2)Used By (1)

Effectra Email Address Formatter
================================

[](#effectra-email-address-formatter)

A lightweight PHP package for representing and formatting email addresses with optional names.
It provides validation, parsing, and factory methods to work with email addresses in a clean and consistent way.

---

Features
--------

[](#features)

- Represent an email address with an optional name.
- Create an `Address` object from a raw string (e.g., `"John Doe "`).
- Validate email addresses.
- Format email addresses in a standard string format.
- Create multiple `Address` instances from an array of data.
- Follows SOLID principles with `AddressInterface`.

---

Installation
------------

[](#installation)

```
composer require effectra/email-address-formatter
```

---

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

```
use Effectra\EmailAddressFormatter\Address;

$address = new Address("john@example.com", "John Doe");

echo $address->getEmail(); // john@example.com
echo $address->getName();  // John Doe
echo $address->format();   // John Doe
```

### Create from String

[](#create-from-string)

```
use Effectra\EmailAddressFormatter\Address;

$address = Address::createFrom("Jane Doe ");

echo $address->getEmail(); // jane@example.com
echo $address->getName();  // Jane Doe
```

### Using AddressFactory

[](#using-addressfactory)

```
use Effectra\EmailAddressFormatter\AddressFactory;

// Single address
$address = AddressFactory::create("mike@example.com", "Mike");

// Multiple addresses
$addresses = AddressFactory::createFromArray([
    "susan@example.com",
    ["email" => "david@example.com", "name" => "David"],
    ["email" => "emma@example.com"] // name is optional
]);

foreach ($addresses as $addr) {
    echo $addr->format() . PHP_EOL;
}
// Output:
// susan@example.com
// David
// emma@example.com
```

### Validation

[](#validation)

```
use Effectra\EmailAddressFormatter\Address;

if (Address::emailValidation("valid@example.com")) {
    echo "Valid email!";
} else {
    echo "Invalid email!";
}
```

---

API Reference
-------------

[](#api-reference)

### `Address` class

[](#address-class)

- `__construct(string $email, string $name = '')`
- `static createFrom(string $addressText): static`
- `getName(): string`
- `getEmail(): string`
- `static emailValidation(string $email): bool`
- `format(): string`
- `__toString(): string`

### `AddressFactory` class

[](#addressfactory-class)

- `static create(string $email, string $name = ''): AddressInterface`
- `static createFromArray(array $data): AddressInterface[]`

### `AddressInterface`

[](#addressinterface)

- `getName(): string`
- `getEmail(): string`
- `static emailValidation(string $email): bool`
- `format(): string`

---

Example Output
--------------

[](#example-output)

```
$address = new Address("alex@example.com", "Alex");

echo $address;
// Output: Alex
```

---

License
-------

[](#license)

This package is open-source and available under the **MIT License**.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance64

Regular maintenance activity

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

220d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e6219ae87e98df8783b2f595b013035dd183c0712afd24045a8acf0a40c3bdf?d=identicon)[effectra](/maintainers/effectra)

---

Top Contributors

[![BMTmohammedtaha](https://avatars.githubusercontent.com/u/95439605?v=4)](https://github.com/BMTmohammedtaha "BMTmohammedtaha (4 commits)")

### Embed Badge

![Health badge](/badges/effectra-email-address-formatter/health.svg)

```
[![Health](https://phpackages.com/badges/effectra-email-address-formatter/health.svg)](https://phpackages.com/packages/effectra-email-address-formatter)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
