diff options
Diffstat (limited to 'app/Census/CensusColumnNationality.php')
| -rw-r--r-- | app/Census/CensusColumnNationality.php | 74 |
1 files changed, 38 insertions, 36 deletions
diff --git a/app/Census/CensusColumnNationality.php b/app/Census/CensusColumnNationality.php index 22b2b9ee90..b9348f6d54 100644 --- a/app/Census/CensusColumnNationality.php +++ b/app/Census/CensusColumnNationality.php @@ -22,45 +22,47 @@ use Fisharebest\Webtrees\Individual; /** * The nationality of the individual. */ -class CensusColumnNationality extends AbstractCensusColumn implements CensusColumnInterface { - /** @var array Convert a country name to a nationality */ - private $nationalities - = [ - 'England' => 'British', - 'Scotland' => 'British', - 'Wales' => 'British', - 'Deutschland' => 'Deutsch', - ]; +class CensusColumnNationality extends AbstractCensusColumn implements CensusColumnInterface +{ + /** @var array Convert a country name to a nationality */ + private $nationalities + = [ + 'England' => 'British', + 'Scotland' => 'British', + 'Wales' => 'British', + 'Deutschland' => 'Deutsch', + ]; - /** - * Generate the likely value of this census column, based on available information. - * - * @param Individual $individual - * @param Individual $head - * - * @return string - */ - public function generate(Individual $individual, Individual $head = null) { - $place = $individual->getBirthPlace()->getGedcomName(); + /** + * Generate the likely value of this census column, based on available information. + * + * @param Individual $individual + * @param Individual $head + * + * @return string + */ + public function generate(Individual $individual, Individual $head = null) + { + $place = $individual->getBirthPlace()->getGedcomName(); - // No birthplace? Assume born in the same country. - if ($place === '') { - $place = $this->place(); - } + // No birthplace? Assume born in the same country. + if ($place === '') { + $place = $this->place(); + } - // 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(); - } - } + // 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 = $this->lastPartOfPlace($place); + $place = $this->lastPartOfPlace($place); - if (array_key_exists($place, $this->nationalities)) { - return $this->nationalities[$place]; - } else { - return $place; - } - } + if (array_key_exists($place, $this->nationalities)) { + return $this->nationalities[$place]; + } else { + return $place; + } + } } |
