PHP code example of artisan / name-of-person

1. Go to this page and download the library: Download artisan/name-of-person library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

artisan / name-of-person example snippets


use Humans\NameOfPerson\PersonName;

$name = new PersonName('Terry Crews');

$name->full;              // => "Terry Crews"
$name->first;             // => "Terry"
$name->last;              // => "Crews"
$name->initials;          // => "TC"
$name->familiar;          // => "Terry C."
$name->abbreviated;       // => "T. Crews"
$name->sorted;            // => "Crews, Terry"
$name->mentionable;       // => "terryc"
$name->possessive;        // => "Terry Crews'"
$name->first->possessive  // => Terry's
$name->last->possessive   // => Crews'

use Humans\NameOfPerson\PersonName;

class User
{
    public function getNameAttribute()
    {
        return new PersonName($this->attributes['full_name']);
    }
}