. */ namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Date; use Fisharebest\Webtrees\Individual; /** * The nationality of the individual. */ class CensusColumnNationality extends AbstractCensusColumn implements CensusColumnInterface { /** * Generate the likely value of this census column, based on available information. * * @param Individual $individual * * @return string */ public function generate(Individual $individual) { $place = $individual->getBirthPlace(); // Did we emigrate or naturalise? foreach ($individual->getFacts('IMMI|EMIG|NATU', true) as $fact) { if (Date::compare($fact->getDate(), $this->date()) <= 0) { $place = $fact->getPlace()->getGedcomName(); } } $place = explode(', ', $place); $place = end($place); if ($place === 'England' || $place === 'Scotland' || $place === 'Wales') { return 'British'; } else { return $place; } } }