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