xref: /webtrees/app/SurnameTradition/DefaultSurnameTradition.php (revision 771ae10a6b066c524545c3bc95fbde7ad19d076c)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2018 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{
23    /** Extract a GIVN from a NAME */
24    const REGEX_GIVN = '~^(?<GIVN>[^/ ]+)~';
25
26    /** Extract a SPFX and SURN from a NAME */
27    const REGEX_SPFX_SURN = '~(?<NAME>/(?<SPFX>[a-z’\']{0,4}(?: [a-z’\']{1,4})*) ?(?<SURN>[^/]*)/)~';
28
29    /** Extract a simple SURN from a NAME */
30    const REGEX_SURN = '~(?<NAME>/(?<SURN>[^/]+)/)~';
31
32    /** Extract two Spanish/Portuguese SURNs from a NAME */
33    const REGEX_SURNS = '~/(?<SURN1>[^ /]+)(?: | y |/ /|/ y /)(?<SURN2>[^ /]+)/~';
34
35    /**
36     * Does this surname tradition change surname at marriage?
37     *
38     * @return bool
39     */
40    public function hasMarriedNames()
41    {
42        return false;
43    }
44
45    /**
46     * Does this surname tradition use surnames?
47     *
48     * @return bool
49     */
50    public function hasSurnames()
51    {
52        return true;
53    }
54
55    /**
56     * What names are given to a new child
57     *
58     * @param string $father_name A GEDCOM NAME
59     * @param string $mother_name A GEDCOM NAME
60     * @param string $child_sex   M, F or U
61     *
62     * @return string[] Associative array of GEDCOM name parts (SURN, _MARNM, etc.)
63     */
64    public function newChildNames(string $father_name, string $mother_name, string $child_sex): array
65    {
66        return [
67            'NAME' => '//',
68        ];
69    }
70
71    /**
72     * What names are given to a new parent
73     *
74     * @param string $child_name A GEDCOM NAME
75     * @param string $parent_sex M, F or U
76     *
77     * @return string[] Associative array of GEDCOM name parts (SURN, _MARNM, etc.)
78     */
79    public function newParentNames(string $child_name, string $parent_sex): array
80    {
81        return [
82            'NAME' => '//',
83        ];
84    }
85
86    /**
87     * What names are given to a new spouse
88     *
89     * @param string $spouse_name A GEDCOM NAME
90     * @param string $spouse_sex  M, F or U
91     *
92     * @return string[] Associative array of GEDCOM name parts (SURN, _MARNM, etc.)
93     */
94    public function newSpouseNames(string $spouse_name, string $spouse_sex): array
95    {
96        return [
97            'NAME' => '//',
98        ];
99    }
100}
101