2017 © Pedro Peláez
 

library name-parser-and-anonymizer

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

image

wwwd3v/name-parser-and-anonymizer

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

  • Sunday, June 3, 2018
  • by wwwd3v
  • Repository
  • 0 Watchers
  • 1 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

Name Parser And Anonymizer

An easy to use name parser with advanced and configurable anonymization options., (*1)

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

Getting Started

Prerequisites

  • PHP 7.2+
  • Composer

Installing

Simply install the composer package:, (*3)

composer require wwwd3v/name-parser-and-anonymizer

Then, at some point in your code, 'new up' a NameParserAndAnonymizer class instance:, (*4)

use Wwwd3v\NameParserAndAnonymizer\NameParserAndAnonymizer;

//...

$parser = new NameParserAndAnonymizer();

Parsing and anonymizing names

Simple names

It is trivial to parse a simple name:, (*5)

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

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

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

Anonymizing names is then very simple:, (*6)

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

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

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

Compound names

Middle names are parsed out and grouped in an array:, (*7)

$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:, (*8)

$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):, (*9)

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

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

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

(string) $name; // 'John R. R. T.', (*11)


## Edge cases ### 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: ```php $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

Simply run the local phpunit:, (*12)

./vendor/bin/phpunit

Contributing

Just open an issue. We will decide on the implementation details and polish up the pull request together., (*13)

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository., (*14)

License

This project is licensed under the MIT License - see the LICENSE.md file for details, (*15)

Acknowledgments

  • European Union

The Versions

03/06 2018

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Orosz

03/06 2018

0.3.0

0.3.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Orosz

03/06 2018

dev-normalize-whitespace

dev-normalize-whitespace

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Orosz

03/06 2018

dev-non-mutating-operations-on-name-string

dev-non-mutating-operations-on-name-string

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Orosz

29/05 2018

0.2.1

0.2.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Orosz

29/05 2018

0.2.0

0.2.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Orosz

29/05 2018

dev-decide-to-keep-middle-names

dev-decide-to-keep-middle-names

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Orosz

29/05 2018

0.1.1

0.1.1.0

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

  Sources   Download

MIT

The Requires

  • php ^7.2

 

The Development Requires

by Peter Orosz

28/05 2018

0.1

0.1.0.0

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

  Sources   Download

MIT

The Requires

  • php ^7.2

 

The Development Requires

by Peter Orosz

28/05 2018

dev-parse-simple-name-to-first-and-last-name

dev-parse-simple-name-to-first-and-last-name

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

  Sources   Download

MIT

The Requires

  • php ^7.2

 

The Development Requires

by Peter Orosz