imliam / php-name-of-person

Present names for English-language applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Name of Person

Latest Version on Packagist Build Status Code Quality Code Coverage Total Downloads License

Present names for English-language applications where a first and last name combined is sufficient. This approach does not cover all possible naming cases, deal with other languages or titles.

This is a rough port of the Ruby package of the same name from Basecamp.

πŸ’Ύ Installation

You can install the package with Composer using the following command:

composer require imliam/php-name-of-person:^1.1

πŸ“ Usage

The package supplies a single class that can be instantiated with a string containing the original name of a person.

The class has a handful of methods that can be called to return different variations of the supplied name.

use ImLiam\NameOfPerson\Name;

$name = new Name('David Heinemeier Hansson');

$name->getFullName();       // "David Heinemeier Hansson"
$name->getFirstName();      // "David"
$name->getLastName();       // "Heinemeier Hansson"
$name->getInitials();       // "DHH"
$name->getInitials(true);   // "D.H.H."
$name->getFamiliar();       // "David H."
$name->getAbbreviated();    // "D. Heinemeier Hansson"
$name->getSorted();         // "Heinemeier Hansson, David"
$name->getMentionable();    // "davidh"
$name->getPossessive();     // "David Heinemeier Hansson's"
$name->getProperName();     // "David Heinemeier Hansson"

These methods take care to handle some of the situations that are often awkward to process and missed when handling names that come from user-input so aren't always reliable.

One such example is that names with particles can be capitalised properly with the getProperName() method.

(new Name("lucas l'amour"))->getProperName(); // "Lucas l'Amour"
(new Name('t. von lieres und wilkau'))->getProperName(); // "T. von Lieres und Wilkau"

βœ… Testing

composer test

πŸ”– Changelog

Please see the changelog file for more information on what has changed recently.

⬆️ Upgrading

Please see the upgrading file for details on upgrading from previous versions.

πŸŽ‰ Contributing

Please see the contributing file and code of conduct for details on contributing to the project.

πŸ”’ Security

If you discover any security related issues, please email liam@liamhammett.com instead of using the issue tracker.

πŸ‘· Credits

♻️ License

The MIT License (MIT). Please see the license file for more information.

About

Present names for English-language applications.

License:MIT License


Languages

Language:PHP 100.0%