HumanNameParser.php in Bibliography & Citation 8
File
src/HumanNameParser.php
View source
<?php
namespace Drupal\bibcite;
use ADCI\FullNameParser\Parser;
class HumanNameParser implements HumanNameParserInterface {
protected $parser;
public function __construct() {
$this->parser = new Parser([
'mandatory_last_name' => FALSE,
'mandatory_middle_name' => FALSE,
]);
}
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(),
];
}
}