/** * Transfer a \Geissler\Converter\Model\Person object into a person string (Lastname, Firstname, Suffix). * * @param \Geissler\Converter\Model\Person $person * @return string */ private function getPerson(Person $person) { $return = array($person->getFamily()); if ($person->getGiven() !== '') { $return[] = $person->getGiven(); } if ($person->getSuffix() !== '') { $return[] = $person->getSuffix(); } return implode(', ', $return); }
/** * Add a person (Geissler\Converter\Model\Person object) to a person collection (Geissler\Converter\Model\Persons). * * @param \Geissler\Converter\Model\Entry $entry * @param array $persons Persons extracted from the BibTeX * @param string $setter Setter method to inject each person, e.g. getAuthor * @return \Geissler\Converter\Model\Entry */ private function createPersons(Entry $entry, $persons, $setter) { $length = count($persons); for ($j = 0; $j < $length; $j++) { $author = new Person(); $author->setGiven($persons[$j][0])->setFamily($persons[$j][2])->setNonDroppingParticle($persons[$j][3])->setDroppingParticle($persons[$j][3]); if ($persons[$j][0] == '') { $author->setGiven($persons[$j][1]); } else { $author->setSuffix($persons[$j][1]); } $entry->{$setter}()->setPerson($author); } return $entry; }
/** * Parse a person into a \Geissler\Converter\Model\Person object. * * @param string $data * @return \Geissler\Converter\Model\Person */ private function getPerson($data) { $person = new Person(); $values = explode(',', $data); $person->setFamily(trim($values[0]))->setGiven(trim($values[1])); if (isset($values[2]) == true) { $person->setSuffix(trim($values[2])); } return $person; }