diff options
| author | Greg Roach <fisharebest@webtrees.net> | 2018-07-16 08:20:33 +0100 |
|---|---|---|
| committer | Greg Roach <fisharebest@webtrees.net> | 2018-07-16 08:20:33 +0100 |
| commit | c1010eda29c0909ed4d5d463f32d32bfefdd4dfe (patch) | |
| tree | fbb656ebc014aa1295ac8e6176f41e89f94b91e7 /app/Census/AbstractCensusColumn.php | |
| parent | 782f08d9bd2bfa06635da947ee34f8e1afd65088 (diff) | |
| download | webtrees-c1010eda29c0909ed4d5d463f32d32bfefdd4dfe.tar.gz webtrees-c1010eda29c0909ed4d5d463f32d32bfefdd4dfe.tar.bz2 webtrees-c1010eda29c0909ed4d5d463f32d32bfefdd4dfe.zip | |
Use PSR2 code style
Diffstat (limited to 'app/Census/AbstractCensusColumn.php')
| -rw-r--r-- | app/Census/AbstractCensusColumn.php | 273 |
1 files changed, 142 insertions, 131 deletions
diff --git a/app/Census/AbstractCensusColumn.php b/app/Census/AbstractCensusColumn.php index bd9564f3f4..40b6041cee 100644 --- a/app/Census/AbstractCensusColumn.php +++ b/app/Census/AbstractCensusColumn.php @@ -23,153 +23,164 @@ use Fisharebest\Webtrees\Individual; /** * Definitions for a census column */ -class AbstractCensusColumn { - /** @var CensusInterface */ - private $census; +class AbstractCensusColumn +{ + /** @var CensusInterface */ + private $census; - /** @var string */ - private $abbr; + /** @var string */ + private $abbr; - /** @var string */ - private $title; + /** @var string */ + private $title; - /** - * Create a column for a census - * - * @param CensusInterface $census - The census to which this column forms part. - * @param string $abbr - The abbrievated on-screen name "BiC" - * @param string $title - The full column heading "Born in the county" - */ - public function __construct(CensusInterface $census, $abbr, $title) { - $this->census = $census; - $this->abbr = $abbr; - $this->title = $title; - } + /** + * Create a column for a census + * + * @param CensusInterface $census - The census to which this column forms part. + * @param string $abbr - The abbrievated on-screen name "BiC" + * @param string $title - The full column heading "Born in the county" + */ + public function __construct(CensusInterface $census, $abbr, $title) + { + $this->census = $census; + $this->abbr = $abbr; + $this->title = $title; + } - /** - * A short version of the column's name. - * - * @return string - */ - public function abbreviation() { - return $this->abbr; - } + /** + * A short version of the column's name. + * + * @return string + */ + public function abbreviation() + { + return $this->abbr; + } - /** - * Find the father of an individual - * - * @param Individual $individual - * - * @return Individual|null - */ - public function father(Individual $individual) { - $family = $individual->getPrimaryChildFamily(); + /** + * Find the father of an individual + * + * @param Individual $individual + * + * @return Individual|null + */ + public function father(Individual $individual) + { + $family = $individual->getPrimaryChildFamily(); - if ($family) { - return $family->getHusband(); - } else { - return null; - } - } + if ($family) { + return $family->getHusband(); + } else { + return null; + } + } - /** - * Find the mother of an individual - * - * @param Individual $individual - * - * @return Individual|null - */ - public function mother(Individual $individual) { - $family = $individual->getPrimaryChildFamily(); + /** + * Find the mother of an individual + * + * @param Individual $individual + * + * @return Individual|null + */ + public function mother(Individual $individual) + { + $family = $individual->getPrimaryChildFamily(); - if ($family) { - return $family->getWife(); - } else { - return null; - } - } + if ($family) { + return $family->getWife(); + } else { + return null; + } + } - /** - * Find the current spouse family of an individual - * - * @param Individual $individual - * - * @return Family|null - */ - public function spouseFamily(Individual $individual) { - // Exclude families that were created after this census date - $families = []; - foreach ($individual->getSpouseFamilies() as $family) { - if (Date::compare($family->getMarriageDate(), $this->date()) <= 0) { - $families[] = $family; - } - } + /** + * Find the current spouse family of an individual + * + * @param Individual $individual + * + * @return Family|null + */ + public function spouseFamily(Individual $individual) + { + // Exclude families that were created after this census date + $families = []; + foreach ($individual->getSpouseFamilies() as $family) { + if (Date::compare($family->getMarriageDate(), $this->date()) <= 0) { + $families[] = $family; + } + } - if (empty($families)) { - return null; - } else { - usort($families, function (Family $x, Family $y) { - return Date::compare($x->getMarriageDate(), $y->getMarriageDate()); - }); + if (empty($families)) { + return null; + } else { + usort($families, function (Family $x, Family $y) { + return Date::compare($x->getMarriageDate(), $y->getMarriageDate()); + }); - return end($families); - } - } + return end($families); + } + } - /** - * When did this census occur - * - * @return Date - */ - public function date() { - return new Date($this->census->censusDate()); - } + /** + * When did this census occur + * + * @return Date + */ + public function date() + { + return new Date($this->census->censusDate()); + } - /** - * The full version of the column's name. - * - * @return string - */ - public function title() { - return $this->title; - } + /** + * The full version of the column's name. + * + * @return string + */ + public function title() + { + return $this->title; + } - /** - * Extract the country (last part) of a place name. - * - * @param string $place - e.g. "London, England" - * - * @return string - e.g. "England" - */ - protected function lastPartOfPlace($place) { - $place = explode(', ', $place); + /** + * Extract the country (last part) of a place name. + * + * @param string $place - e.g. "London, England" + * + * @return string - e.g. "England" + */ + protected function lastPartOfPlace($place) + { + $place = explode(', ', $place); - return end($place); - } + return end($place); + } - /** - * Remove the country of a place name, where it is the same as the census place - * - * @param string $place - e.g. "London, England" - * - * @return string - e.g. "London" (for census of England) and "London, England" elsewhere - */ - protected function notCountry($place) { - $parts = explode(', ', $place); + /** + * Remove the country of a place name, where it is the same as the census place + * + * @param string $place - e.g. "London, England" + * + * @return string - e.g. "London" (for census of England) and "London, England" elsewhere + */ + protected function notCountry($place) + { + $parts = explode(', ', $place); - if (end($parts) === $this->place()) { - return implode(', ', array_slice($parts, 0, -1)); - } else { - return $place; - } - } + if (end($parts) === $this->place()) { + return implode(', ', array_slice($parts, 0, -1)); + } else { + return $place; + } + } - /** - * Where did this census occur - * - * @return string - */ - public function place() { - return $this->census->censusPlace(); - } + /** + * Where did this census occur + * + * @return string + */ + public function place() + { + return $this->census->censusPlace(); + } } |
