You are here

public function HumanNameParser::parse in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x src/HumanNameParser.php \Drupal\bibcite\HumanNameParser::parse()

Parse the name into its constituent parts.

Parameters

string $name: Human name string.

Return value

array Parsed name parts.

Throws

\ADCI\FullNameParser\Exception\NameParsingException

Overrides HumanNameParserInterface::parse

File

src/HumanNameParser.php, line 40

Class

HumanNameParser
Human name parser service.

Namespace

Drupal\bibcite

Code

public function parse($name) {
  $parsed_name = $this->parser
    ->parse($name);
  return [
    'leading_title' => $parsed_name
      ->getLeadingInitial(),
    'prefix' => $parsed_name
      ->getAcademicTitle(),
    'first_name' => $parsed_name
      ->getFirstName(),
    'middle_name' => $parsed_name
      ->getMiddleName(),
    'last_name' => $parsed_name
      ->getLastName(),
    'nick' => $parsed_name
      ->getNicknames(),
    'suffix' => $parsed_name
      ->getSuffix(),
  ];
}