michael-rubel / laravel-value-objects

A bunch of general-purpose value objects you can use in your Laravel application.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FullName doesn’t work with multi-word surnames

RicLeP opened this issue · comments

My surname is ‘Le Poidevin’ but this gets changed to just ‘Poidevin’.

$name = new FullName('Richard Le Poidevin');

dd($name->toArray());

//
array:3 [
  "fullName" => "Richard Le Poidevin"
  "firstName" => "Richard"
  "lastName" => "Poidevin" // should be: Le Poidevin
]

It’s a tricky one, where should you break, always the first space? Some people may have multiple first names but I think that’s more likely to be hyphenated whilst surnames with ‘Le’ etc. are pretty common. It’s still better than what usually happens to my name - ‘Richard L’ 😅

Maybe the default behaviour should be firstName is the first word and everything else forms lastName?

Likely fixed in #17 🙂