Add function for assembling display names by given name and family name

This commit is contained in:
2021-05-04 23:57:30 +02:00
parent bde3c2cb9e
commit 6dcdb3aff6
2 changed files with 38 additions and 0 deletions

View File

@ -69,6 +69,25 @@ final class NodaNameSplitter {
}
/**
* Assembles first name and given name into a common name as pronounced in the given language.
*
* @param string $givenName Given name of the actor.
* @param string $familyName Family name of the actor.
* @param string $toAdd Additional information to add to the name.
*
* @return string
*/
public function assembleNameParts(string $givenName, string $familyName, string $toAdd = ''):string {
if (in_array($this->_lang, self::LANGS_FAMILY_NAME_FIRST, true)) {
return trim($familyName) . ' ' . trim($givenName) . $toAdd;
}
return trim($givenName . ' ' . $familyName) . $toAdd;
}
/**
* Constructor.
*