. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Individual; use function strlen; final readonly class CensusColumnBirthPlace extends AbstractCensusColumn implements CensusColumnInterface { public function generate(Individual $individual, Individual $head): string { $birth_place = $individual->getBirthPlace()->gedcomName(); $census_place = $this->place(); // Ignore the census country if ($birth_place === $census_place) { return ''; } if (substr($birth_place, -strlen($census_place) - 2) === ', ' . $census_place) { return substr($birth_place, 0, -strlen($census_place) - 2); } return $birth_place; } }