druc / person-name
Presents one's name in various formats
v0.0.2
2018-09-08 14:04 UTC
Requires
- php: >=7.0.0
Requires (Dev)
- phpunit/phpunit: 6.*
- squizlabs/php_codesniffer: ^2.3
This package is auto-updated.
Last update: 2024-11-09 03:34:05 UTC
README
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
- Constantin Druc
- Basecamp's rails version - basecamp/name_of_person
- All Contributors
License
The MIT License (MIT). Please see License File for more information.