Download the PHP package adci/full-name-parser without Composer
On this page you can find all versions of the php package adci/full-name-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package full-name-parser
full-name-parser
Description
FullNameParser is designed to parse large batches of full names in multiple inconsistent formats, as from a database, and continue processing without error, even if given some unparsable garbage entries.
FullNameParser::parse():
- accepts a string containing a person's full name, in any format,
- analyzes and attempts to detect the format of that name,
- (if possible) parses the name into its component parts, and
- (by default) returns an object containing all individual parts of the name:
- title (string): title(s) (e.g. "Ms." or "Dr.")
- first (string): first name or initial
- middle (string): middle name(s) or initial(s)
- last (string): last name or initial
- nick (string): nickname(s)
- suffix (string): suffix(es) (e.g. "Jr.", "II", or "Esq.")
- error (array of strings): any parsing error messages
Optionally, FullNameParser can also:
- return only the specified part of a name as a string (or errors as an array)
- always fix or ignore the letter case of the returned parts (the default is to fix the case only when the original input is all upper or all lowercase)
- stop on errors (the default is to return warning messages in the output, but never throw a PHP error, no matter how mangled the input)
Now FullNameParser cannot:
- detect more variations of name prefixes, suffixes, and titles (the default detects 29 prefixes, 19 suffixes, 16 titles, and 8 conjunctions, but in future it can be set to detect 97 prefixes, 23 suffixes, and 204 titles instead)
If this is not what you're looking for, is overkill for your application, or is in the wrong language, check the "Credits" section at the end of this file for links to other parsers which may suit your needs better.
Use
Basic Use
Advanced options
suffixes(array of string, optional): Override list of suffixes to search. These suffixes can end with dot in source name string. Though you must not include dots in these suffixes, dots are handled automatically on parsing.
numeral_suffixes(array of string, optional): Override list of numeral suffixes to search. Do not contain trailing dots.
prefixes(array of string, optional): Override list of prefixes to search.
academic_titles(array of string, optional): Override list of academic titles to search.
part(string, optional): The name of a single part to return.
- 'all' (default) = Return an object containing all name parts.
- 'title' = Return only the title(s) as a string (or an empty string).
- 'first' = Return only the first name as a string (or an empty string).
- 'middle' = Return only the middle name(s) as a string (or an empty string).
- 'last' = Return only the last name as a string (or an empty string).
- 'nick' = Return only the nickname(s) as a string (or an empty string).
- 'suffix' = Return only the suffix(es) as a string (or an empty string).
- 'error' = Return only the array of parsing error messages (or an empty array).
fix_case (bool|integer, optional): Fix case of output name.
- 0 or false (default) = Never fix the case (retain and output same case as input name).
- 1 or true = Always fix case of output, even if input is mixed case.
throws (bool|integer, optional): Makes parsing errors throw PHP errors.
- 0 or false = Return warnings about parsing errors, but continue.
- 1 or true (default) = If a parsing error is found, throw a PHP error.
mandatory_first_name(bool|integer, optional): Throw error if first name not found.
- 0 or false = Does not throw error.
- 1 or true (default) = Throw error.
mandatory_last_name(bool|integer, optional): Throw error if last name not found.
- 0 or false = Does not throw error.
- 1 or true (default) = Throw error.
mandatory_middle_name(bool|integer, optional): Throw warning if a lot of middle names.
- 0 or false = Does not throw warning.
- 1 or true (default) = Throw warning.
Advanced Use
Reporting Bugs
If you find a name this function does not parse correctly, or any other bug, please report it here: https://github.com/adci/full-name-parser/issues
Credits and precursors
This parser is based on and compatible with davidgorges/human-name-parser.
It also implements all tests and most of additional functionality from dschnelldavis/parse-full-name.
All versions of full-name-parser with dependencies
ext-mbstring Version *