You are here

class ContributorObject in Bibliography Module 7.2

Contributor Match Object

A simple value object that contains the properties for a contributor

Hierarchy

Expanded class hierarchy of ContributorObject

File

lib/msrc-authortool/src/Analyzer/ContributorObject.php, line 18

Namespace

Analyzer
View source
class ContributorObject extends MatchObject {

  /**
   * @var string
   * First Name
   */
  public $firstName;

  /**
   * @var string
   * Last Name
   */
  public $lastName;

  /**
   * @var string
   * Middle Name
   */
  public $middleName;

  /**
   * @var string
   * First Initial
   */
  public $firstInitial;

  /**
   * @var string
   * Middle Initial
   */
  public $middleInitial;

  /**
   * @var string
   * Second Middle Initial
   */
  public $secondMiddleInitial;

  /**
   * @var string
   * Organization
   */
  public $organization;

  /**
   * @var string
   * Normalized suffixes (jr., sr. or whatever)
   */
  public $suffix;

  /**
   * @var string
   * Prefix for last name (von, van, van der, or whatever)
   */
  public $lastNamePrefix;

  /**
   * @var string
   * Original string
   */
  public $originalString;

  // --------------------------------------------------------------

  /**
   * Map a suffix
   *
   * @param string $suffix  A common suffix (Jr., Sr. etc)
   * @return string         A normalized version of that suffix
   */
  public function mapSuffix($suffix) {

    //get the letters and numbers only
    preg_match("/[a-z0-9]/i", $suffix, $matches);
    $suffix = implode('', array_slice($matches, 1));
    $suffixMap = $this
      ->getSuffixMap();
    return isset($suffixMap[$suffix]) ? $suffixMap[$suffix] : false;
  }

  // --------------------------------------------------------------

  /**
   * Get an array of common suffixes
   *
   * @return array  Keys are normalized suffixes, values are proper suffixes
   */
  public function getSuffixMap() {
    return array(
      '2nd' => '2nd',
      '3rd' => '3rd',
      'phd' => 'Ph.D.',
      'ms' => 'M.S.',
      'ma' => 'M.A.',
      'jr' => 'Jr.',
      'sr' => 'Sr.',
      'psyd' => 'Psy.D.',
      'frcpi' => 'F.R.C.P.I.',
      '2' => '2nd',
      'II' => '2nd',
      'III' => '3rd',
      'IV' => '4th',
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContributorObject::$firstInitial public property First Initial
ContributorObject::$firstName public property First Name
ContributorObject::$lastName public property Last Name
ContributorObject::$lastNamePrefix public property Prefix for last name (von, van, van der, or whatever)
ContributorObject::$middleInitial public property Middle Initial
ContributorObject::$middleName public property Middle Name
ContributorObject::$organization public property Organization
ContributorObject::$originalString public property Original string
ContributorObject::$secondMiddleInitial public property Second Middle Initial
ContributorObject::$suffix public property Normalized suffixes (jr., sr. or whatever)
ContributorObject::getSuffixMap public function Get an array of common suffixes
ContributorObject::mapSuffix public function Map a suffix
MatchObject::factory public static function Factory method
MatchObject::__set public function Set magic method prevents setting undefined variables
MatchObject::__toString public function To string magic method