jasonpriem / HumanNameParser.php

Returns the parts (leading initial, first, middle, last, suffix) of a name from a string.
MIT License
108 stars 42 forks source link

Cases with a single name throws an exception #10

Open gabrielalack opened 9 years ago

gabrielalack commented 9 years ago

Hi,

So I tried using your library to parse customer names coming in from an online ordering system.

Some names tend to just be one word, like "Henry". Your library throws an exception and halts execution if I try to get a last name from cases where there is only a single word. Why not just return ""? Or maybe an option for how strict it should be when returning name parts?

Like level 1, halt for all missing pieces level 2, just return empty string for missing pieces with no errors

gabeguz commented 9 years ago

I created a pull request to deal with this issue, not sure if it's the correct approach or if it's even something you'd be interested in @jasonpriem Feel free to review and let me know if you'd like me to change anything. PR is here for reference: https://github.com/jasonpriem/HumanNameParser.php/pull/12