You are here

protected function ContributorNames::cleanUp in Bibliography Module 7.2

Cleanup a matched object

Normalizes suffixes, and fills in initials.

Parameters

ContributorObject $obj:

Return value

ContributorObject

1 call to ContributorNames::cleanUp()
ContributorNames::analyze in lib/msrc-authortool/src/Analyzer/ContributorNames.php
Analyze a string

File

lib/msrc-authortool/src/Analyzer/ContributorNames.php, line 162

Class

ContributorNames
Match Contributor Names with Predefined Regex

Namespace

Analyzer

Code

protected function cleanUp(ContributorObject $obj) {

  //If there is a suffix, attempt to normalize it
  if ($obj->suffix) {
    $obj->suffix = $obj
      ->mapSuffix($obj->suffix);
  }

  //If middleName is a single character, and no middle initial,

  //move the middleName to the middleInitial
  if (strlen($obj->middleName) == 1 && !$obj->middleInitial) {
    $obj->middleInitial = $obj->middleName;
    $obj->middleName = null;
  }

  //If firstName is a single character and no first initial,

  //move the firstName to the firstInitial
  if (strlen($obj->firstName) == 1 && !$obj->firstInitial) {
    $obj->firstInitial = $obj->firstName;
    $obj->firstName = null;
  }

  //If middleName and no middle initial, fill that in
  if ($obj->middleName && !$obj->middleInitial) {
    $obj->middleInitial = $obj->middleName[0];
  }

  //If firstName and no first initial, fill that in
  if ($obj->firstName && !$obj->firstInitial) {
    $obj->firstInitial = $obj->firstName[0];
  }
  return $obj;
}