PHP 클래스 FullNameParser

Author: Josh Fraser Contribution from Clive Verrall www.cliveverrall.com February 2016 other contributions: - eric willis list of honorifics - TomThak for raising issue #16 and providing wikepedia resource - atla5 for closing the issue.
파일 보기 프로젝트 열기: joshfraser/php-name-parser 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$dict - Common honorific prefixes (english) - Common compound surname identifiers - Common suffixes (lineage and professional) Note: longer professional titles should appear earlier in the array than shorter titles to reduce the risk of mis-identification e.g. BEng before BE Also note that case and periods are part of the matching for professional titles and therefore need to be correct, there are no case conversions
$not_nicknames

공개 메소드들

메소드 설명
break_words ( string $name ) : array Breaks name into individual words
fix_case ( $word ) # ucfirst all upper/lower strings, but leave camelcase words alone
get_pro_suffix ( string $name ) : mixed Checks for the existence of, and returns professional suffix
parse ( string $name ) : array Parse Static entry point.
parse_name ( $full_name ) : array This is the primary method which calls all other methods
safe_ucfirst ( $seperator, $word ) # helper public function for fix_case

보호된 메소드들

메소드 설명
get_nickname ( string $name ) : mixed Function to check name for existence of nickname based on these stipulations - String wrapped in parentheses (string) - String wrapped in double quotes "string" x String wrapped in single quotes 'string'
is_camel_case ( string $word ) : boolean Checks for camelCase words such as McDonald and MacElroy
is_compound ( string $word ) : boolean Checks our dictionary of compound indicators to see if last name is compound
is_initial ( string $word ) : boolean Test string to see if it's a single letter/initial (period optional)
is_line_suffix ( string $word, string $name ) : mixed Checks word against array of common lineage suffixes
is_salutation ( string $word ) : boolean Checks word against list of common honorific prefixes

메소드 상세

break_words() 공개 메소드

Breaks name into individual words
public break_words ( string $name ) : array
$name string the full name you wish to parse
리턴 array full list of words broken down by spaces

fix_case() 공개 메소드

# ucfirst all upper/lower strings, but leave camelcase words alone
public fix_case ( $word )

get_nickname() 보호된 메소드

I removed the check for strings in single quotes 'string' due to possible conflicts with names that may include apostrophes. Arabic transliterations, for example
protected get_nickname ( string $name ) : mixed
$name string the name you wish to test against
리턴 mixed returns nickname if exists, false otherwise

get_pro_suffix() 공개 메소드

Checks for the existence of, and returns professional suffix
public get_pro_suffix ( string $name ) : mixed
$name string the name you wish to test
리턴 mixed returns the suffix if exists, false otherwise

is_camel_case() 보호된 메소드

Checks for camelCase words such as McDonald and MacElroy
protected is_camel_case ( string $word ) : boolean
$word string the single word you wish to test
리턴 boolean

is_compound() 보호된 메소드

Checks our dictionary of compound indicators to see if last name is compound
protected is_compound ( string $word ) : boolean
$word string the single word you wish to test
리턴 boolean

is_initial() 보호된 메소드

Test string to see if it's a single letter/initial (period optional)
protected is_initial ( string $word ) : boolean
$word string the single word you wish to test
리턴 boolean

is_line_suffix() 보호된 메소드

Checks word against array of common lineage suffixes
protected is_line_suffix ( string $word, string $name ) : mixed
$word string the single word you wish to test
$name string full name for context in determining edge-cases
리턴 mixed boolean if false, string if true (returns suffix)

is_salutation() 보호된 메소드

Checks word against list of common honorific prefixes
protected is_salutation ( string $word ) : boolean
$word string the single word you wish to test
리턴 boolean

parse() 공개 정적인 메소드

Parse Static entry point.
public static parse ( string $name ) : array
$name string the full name you wish to parse
리턴 array returns associative array of name parts

parse_name() 공개 메소드

This is the primary method which calls all other methods
public parse_name ( $full_name ) : array
리턴 array returns associative array of name parts

safe_ucfirst() 공개 메소드

# helper public function for fix_case
public safe_ucfirst ( $seperator, $word )

프로퍼티 상세

$dict 보호되어 있는 프로퍼티

- Common honorific prefixes (english) - Common compound surname identifiers - Common suffixes (lineage and professional) Note: longer professional titles should appear earlier in the array than shorter titles to reduce the risk of mis-identification e.g. BEng before BE Also note that case and periods are part of the matching for professional titles and therefore need to be correct, there are no case conversions
protected $dict

$not_nicknames 보호되어 있는 프로퍼티

protected $not_nicknames