. */ declare(strict_types=1); namespace Fisharebest\Webtrees\SurnameTradition; use Fisharebest\Webtrees\Individual; /** * Children take their father’s surname. Wives take their husband’s surname. */ class PaternalSurnameTradition extends PatrilinealSurnameTradition { /** * What name is given to a new parent * * @param Individual $child * @param string $sex * * @return array */ public function newParentNames(Individual $child, string $sex): array { if ($sex === 'F' && preg_match(self::REGEX_SPFX_SURN, $this->extractName($child), $match)) { $name = $match['NAME']; $spfx = $match['SPFX']; $surn = $match['SURN']; return [ $this->buildName('//', ['TYPE' => 'birth']), $this->buildName($name, ['TYPE' => 'married', 'SPFX' => $spfx, 'SURN' => $surn]), ]; } return parent::newParentNames($child, $sex); } /** * What names are given to a new spouse * * @param Individual $spouse * @param string $sex * * @return array */ public function newSpouseNames(Individual $spouse, string $sex): array { if ($sex === 'F' && preg_match(self::REGEX_SPFX_SURN, $this->extractName($spouse), $match)) { $name = $match['NAME']; $spfx = $match['SPFX']; $surn = $match['SURN']; return [ $this->buildName('//', ['TYPE' => 'birth']), $this->buildName($name, ['TYPE' => 'married', 'SPFX' => $spfx, 'SURN' => $surn]), ]; } return parent::newSpouseNames($spouse, $sex); } }