/** * Format the given name segment/part. * * @param string $part The part. * * @return S */ protected function format($part) { $part = S::create($part); switch ($part->substr(0, 2)) { case 'Pr': return $part->replace('Prefix', $this->tryGetLongVersion($this->name->getPrefix())); case 'Fi': return $part->replace('First', $this->tryGetLongVersion($this->name->getFirst())); case 'Mi': return $part->replace('Middle', $this->tryGetLongVersion($this->name->getMiddle())); case 'La': return $part->replace('Last', $this->tryGetLongVersion($this->name->getLast())); case 'P.': return $part->replace('P.', $this->tryGetShortVersion($this->name->getPrefix())); case 'F.': return $part->replace('F.', $this->tryGetShortVersion($this->name->getFirst())); case 'M.': return $part->replace('M.', $this->tryGetShortVersion($this->name->getMiddle())); case 'L.': return $part->replace('L.', $this->tryGetShortVersion($this->name->getLast())); default: return $part; } }