michael-rubel / laravel-value-objects

A bunch of general-purpose value objects you can use in your Laravel application.
MIT License
188 stars 13 forks source link

FullName doesn’t work with multi-word surnames #11

Closed RicLeP closed 1 year ago

RicLeP commented 1 year ago

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?

michael-rubel commented 1 year ago

Likely fixed in #17 🙂