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