You are here

public function HumanNameParser_Parser::setName in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 includes/Parser.php \HumanNameParser_Parser::setName()

Sets name string and parses it. Takes Name object or a simple string (converts the string into a Name obj), parses and loads its constituant parts.

Parameters

mixed $name: Either a name as a string or as a Name object.

2 calls to HumanNameParser_Parser::setName()
HumanNameParser_Parser::parseName in includes/Parser.php
HumanNameParser_Parser::__construct in includes/Parser.php
Constructor.

File

includes/Parser.php, line 77

Class

HumanNameParser_Parser
Works with a Name object to parse out the parts of a name.

Code

public function setName($name = NULL, $category = NULL) {
  if ($name) {
    $this->category == $category;

    // This is mostly for testing.
    if (is_object($name) && get_class($name) == "HumanNameParser_Name") {
      $this->name = $name;
    }
    elseif (is_array($name) && isset($name['name'])) {
      $this->name = new HumanNameParser_Name($name['name']);
      $this->nameParts = $name;
    }
    else {
      $this->name = new HumanNameParser_Name($name);
    }
    $this->leadingInit = "";
    $this->first = "";
    $this->nicknames = "";
    $this->middle = "";
    $this->last = "";
    $this->suffix = "";
    if ($this->category == 5 || $this->type == 5) {
      $this->last = $name;
      $this->literal = TRUE;
    }
    else {
      $this
        ->parse();
    }
  }
}