PHPackages                             wwwd3v/name-parser-and-anonymizer - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. wwwd3v/name-parser-and-anonymizer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wwwd3v/name-parser-and-anonymizer
=================================

An easy to use name parser with advanced and configurable anonymization.

0.3.0(7y ago)117MITPHPPHP ^7.2

Since May 28Pushed 7y agoCompare

[ Source](https://github.com/wwwd3v/name-parser-and-anonymizer)[ Packagist](https://packagist.org/packages/wwwd3v/name-parser-and-anonymizer)[ RSS](/packages/wwwd3v-name-parser-and-anonymizer/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (2)Versions (10)Used By (0)

Name Parser And Anonymizer
==========================

[](#name-parser-and-anonymizer)

An easy to use name parser with **advanced and configurable** anonymization options.

Inspired by the European Union's GDPR, this library is very useful for performing mandatory personal data anonymization.

Getting Started
---------------

[](#getting-started)

### Prerequisites

[](#prerequisites)

- PHP 7.2+
- Composer

### Installing

[](#installing)

Simply install the composer package:

```
composer require wwwd3v/name-parser-and-anonymizer

```

Then, at some point in your code, 'new up' a `NameParserAndAnonymizer` class instance:

```
use Wwwd3v\NameParserAndAnonymizer\NameParserAndAnonymizer;

//...

$parser = new NameParserAndAnonymizer();
```

Parsing and anonymizing names
-----------------------------

[](#parsing-and-anonymizing-names)

### Simple names

[](#simple-names)

It is trivial to parse a simple name:

```
$name = $parser->parse('John Steinbeck');

$name->getFirstName(); // 'John
$name->getLastName();  // 'Steinbeck'

(string) $name;        // 'John Steinbeck'
```

Anonymizing names is then very simple:

```
$name = $parser->parse('John Steinbeck')->anonymize();

$name->getFirstName(); // 'John
$name->getLastName();  // 'S.'

(string) $name;        // 'John S.'
```

### Compound names

[](#compound-names)

Middle names are parsed out and grouped in an array:

```
$name = $parser->parse('John Ronald Reuel Tolkien');

$name->getFirstName();   // 'John
$name->getMiddleNames(); // ['Ronald', 'Reuel']
$name->getLastName();    // 'Tolkien'

(string) $name;        // 'John Ronald Reuel Tolkien'
```

As a part of the anonymization process, the middle names are dropped:

```
$name = $parser->parse('John Ronald Reuel Tolkien')->anonymize();

$name->getFirstName();   // 'John
$name->getMiddleNames(); // []
$name->getLastName();    // 'T.'

(string) $name;        // 'John T.'
```

Optionally, you can decide to `keep` or `anonymize` the middle names (rather than to `discard` them):

```
$name = $parser->parse('John Ronald Reuel Tolkien')->anonymize([
    'middleNames' => 'keep',
]);

(string) $name; // 'John Ronald Reuel T.'
```

```
$name = $parser->parse('John Ronald Reuel Tolkien')->anonymize([
    'middleNames' => 'anonymize',
]);

(string) $name; // 'John R. R. T.'
```

Edge cases
----------

[](#edge-cases)

### Excessive whitespace

[](#excessive-whitespace)

All the excessive whitespace is **automatically removed**. The resulting string representation of a parsed name **always** consists of names divided by a **single space** character:

```
$name = $parser->parse(' John   Ronald    Reuel           Tolkien  ');

$name->getFirstName();   // 'John
$name->getMiddleNames(); // ['Ronald', 'Reuel']
$name->getLastName();    // 'Tolkien'

(string) $name;        // 'John Ronald Reuel Tolkien'
```

Running the tests
-----------------

[](#running-the-tests)

Simply run the local phpunit:

```
./vendor/bin/phpunit

```

Contributing
------------

[](#contributing)

Just open an issue. We will decide on the implementation details and polish up the pull request together.

Versioning
----------

[](#versioning)

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/wwwd3v/name-parser-and-anonymizer/tags).

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

Acknowledgments
---------------

[](#acknowledgments)

- European Union

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

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

Every ~1 days

Total

5

Last Release

2900d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f67d26c2ebed5c68504bdb5cbe107e499843c5969193551584dab1f9b7a5fa09?d=identicon)[wwwd3v](/maintainers/wwwd3v)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wwwd3v-name-parser-and-anonymizer/health.svg)

```
[![Health](https://phpackages.com/badges/wwwd3v-name-parser-and-anonymizer/health.svg)](https://phpackages.com/packages/wwwd3v-name-parser-and-anonymizer)
```

###  Alternatives

[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k234.7M20.6k](/packages/friendsofphp-php-cs-fixer)[symfony/rate-limiter

Provides a Token Bucket implementation to rate limit input and output in your application

26847.2M147](/packages/symfony-rate-limiter)[symfony/ldap

Provides a LDAP client for PHP on top of PHP's ldap extension

1407.5M46](/packages/symfony-ldap)[php-soap/ext-soap-engine

An ext-soap engine implementation

443.2M7](/packages/php-soap-ext-soap-engine)[phpbench/container

Simple, configurable, service container.

1512.9M6](/packages/phpbench-container)[symfony/ux-toggle-password

Toggle visibility of password inputs for Symfony Forms

26508.0k5](/packages/symfony-ux-toggle-password)

PHPackages © 2026

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