1323788f4SGreg Roach<?php 2323788f4SGreg Roach/** 3323788f4SGreg Roach * webtrees: online genealogy 41062a142SGreg Roach * Copyright (C) 2018 webtrees development team 5323788f4SGreg Roach * This program is free software: you can redistribute it and/or modify 6323788f4SGreg Roach * it under the terms of the GNU General Public License as published by 7323788f4SGreg Roach * the Free Software Foundation, either version 3 of the License, or 8323788f4SGreg Roach * (at your option) any later version. 9323788f4SGreg Roach * This program is distributed in the hope that it will be useful, 10323788f4SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 11323788f4SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12323788f4SGreg Roach * GNU General Public License for more details. 13323788f4SGreg Roach * You should have received a copy of the GNU General Public License 14323788f4SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 15323788f4SGreg Roach */ 16*e7f56f2aSGreg Roachdeclare(strict_types=1); 17*e7f56f2aSGreg Roach 18323788f4SGreg Roachnamespace Fisharebest\Webtrees\SurnameTradition; 19323788f4SGreg Roach 20323788f4SGreg Roach/** 21323788f4SGreg Roach * Children take their mother’s surname. 22323788f4SGreg Roach */ 23c1010edaSGreg Roachclass MatrilinealSurnameTradition extends DefaultSurnameTradition implements SurnameTraditionInterface 24c1010edaSGreg Roach{ 25323788f4SGreg Roach /** 26323788f4SGreg Roach * What names are given to a new child 27323788f4SGreg Roach * 28323788f4SGreg Roach * @param string $father_name A GEDCOM NAME 29323788f4SGreg Roach * @param string $mother_name A GEDCOM NAME 30323788f4SGreg Roach * @param string $child_sex M, F or U 31323788f4SGreg Roach * 32323788f4SGreg Roach * @return string[] Associative array of GEDCOM name parts (SURN, _MARNM, etc.) 33323788f4SGreg Roach */ 34771ae10aSGreg Roach public function newChildNames(string $father_name, string $mother_name, string $child_sex): array 35c1010edaSGreg Roach { 36323788f4SGreg Roach if (preg_match(self::REGEX_SPFX_SURN, $mother_name, $match)) { 3713abd6f3SGreg Roach return array_filter([ 38323788f4SGreg Roach 'NAME' => $match['NAME'], 39323788f4SGreg Roach 'SPFX' => $match['SPFX'], 40323788f4SGreg Roach 'SURN' => $match['SURN'], 4113abd6f3SGreg Roach ]); 42b2ce94c6SRico Sonntag } 43b2ce94c6SRico Sonntag 4413abd6f3SGreg Roach return [ 45323788f4SGreg Roach 'NAME' => '//', 4613abd6f3SGreg Roach ]; 47323788f4SGreg Roach } 48323788f4SGreg Roach 49323788f4SGreg Roach /** 50323788f4SGreg Roach * What names are given to a new parent 51323788f4SGreg Roach * 52323788f4SGreg Roach * @param string $child_name A GEDCOM NAME 53323788f4SGreg Roach * @param string $parent_sex M, F or U 54323788f4SGreg Roach * 55323788f4SGreg Roach * @return string[] Associative array of GEDCOM name parts (SURN, _MARNM, etc.) 56323788f4SGreg Roach */ 57771ae10aSGreg Roach public function newParentNames(string $child_name, string $parent_sex): array 58c1010edaSGreg Roach { 59323788f4SGreg Roach if ($parent_sex === 'F' && preg_match(self::REGEX_SPFX_SURN, $child_name, $match)) { 6013abd6f3SGreg Roach return array_filter([ 61323788f4SGreg Roach 'NAME' => $match['NAME'], 62323788f4SGreg Roach 'SPFX' => $match['SPFX'], 63323788f4SGreg Roach 'SURN' => $match['SURN'], 6413abd6f3SGreg Roach ]); 65b2ce94c6SRico Sonntag } 66b2ce94c6SRico Sonntag 6713abd6f3SGreg Roach return [ 68323788f4SGreg Roach 'NAME' => '//', 6913abd6f3SGreg Roach ]; 70323788f4SGreg Roach } 71323788f4SGreg Roach} 72