druc/person-name

Presents one's name in various formats

v0.0.2 2018-09-08 14:04 UTC

This package is auto-updated.

Last update: 2024-11-09 03:34:05 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

PHP package to present one's name in various formats (doesn't include titulations).

Install

Via Composer

$ composer require druc/person-name

Usage

<?php
// Create instance
$name = PersonName::make('Constantin Druc');

// Get full name
$name->full; // Constantin Druc

// Get first name
$name->first; // Constantin

// Get last name
$name->last; // Druc

// Get name initials
$name->initials; // CD

// Get familiar name
$name->familiar; // Constantin D.

// Get abbreviated name
$name->abbreviated; // C. Druc

// Get sorted name
$name->sorted; // Druc, Constantin

// Get mentionable name
$name->mentionable; // constantind

// Get possessive name
$name->possessive; // Constantin Druc's

Laravel usage

Initially I wanted to build a Laravel-only package but thinking about it, you can always use an accessor like this:

<?php
// in App/User.php

public function getNameAttribute() 
{
    return PersonName::make($this->attributes['name']);
}

// Somewhere in your app
$user->name->familiar;

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

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

Credits

License

The MIT License (MIT). Please see License File for more information.