1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2021 webtrees development team 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <https://www.gnu.org/licenses/>. 16 */ 17 18declare(strict_types=1); 19 20namespace Fisharebest\Webtrees\SurnameTradition; 21 22/** 23 * All family members keep their original surname 24 */ 25class DefaultSurnameTradition implements SurnameTraditionInterface 26{ 27 /** Extract a GIVN from a NAME */ 28 protected const REGEX_GIVN = '~^(?<GIVN>[^/ ]+)~'; 29 30 /** Extract a SPFX and SURN from a NAME */ 31 protected const REGEX_SPFX_SURN = '~(?<NAME>/(?<SPFX>[a-z’\']{0,4}(?: [a-z’\']{1,4})*) ?(?<SURN>[^/]*)/)~'; 32 33 /** Extract a simple SURN from a NAME */ 34 protected const REGEX_SURN = '~(?<NAME>/(?<SURN>[^/]+)/)~'; 35 36 /** Extract two Spanish/Portuguese SURNs from a NAME */ 37 protected const REGEX_SURNS = '~/(?<SURN1>[^ /]+)(?: | y |/ /|/ y /)(?<SURN2>[^ /]+)/~'; 38 39 /** 40 * Does this surname tradition change surname at marriage? 41 * 42 * @return bool 43 */ 44 public function hasMarriedNames(): bool 45 { 46 return false; 47 } 48 49 /** 50 * Does this surname tradition use surnames? 51 * 52 * @return bool 53 */ 54 public function hasSurnames(): bool 55 { 56 return true; 57 } 58 59 /** 60 * What names are given to a new child 61 * 62 * @param string $father_name A GEDCOM NAME 63 * @param string $mother_name A GEDCOM NAME 64 * @param string $child_sex M, F or U 65 * 66 * @return array<string,string> Associative array of GEDCOM name parts (SURN, _MARNM, etc.) 67 */ 68 public function newChildNames(string $father_name, string $mother_name, string $child_sex): array 69 { 70 return [ 71 'NAME' => '//', 72 ]; 73 } 74 75 /** 76 * What names are given to a new parent 77 * 78 * @param string $child_name A GEDCOM NAME 79 * @param string $parent_sex M, F or U 80 * 81 * @return array<string,string> Associative array of GEDCOM name parts (SURN, _MARNM, etc.) 82 */ 83 public function newParentNames(string $child_name, string $parent_sex): array 84 { 85 return [ 86 'NAME' => '//', 87 ]; 88 } 89 90 /** 91 * What names are given to a new spouse 92 * 93 * @param string $spouse_name A GEDCOM NAME 94 * @param string $spouse_sex M, F or U 95 * 96 * @return array<string,string> Associative array of GEDCOM name parts (SURN, _MARNM, etc.) 97 */ 98 public function newSpouseNames(string $spouse_name, string $spouse_sex): array 99 { 100 return [ 101 'NAME' => '//', 102 ]; 103 } 104} 105