xref: /webtrees/app/SurnameTradition/IcelandicSurnameTradition.php (revision 323788f4145f5a5554b028e0581a6e2063364968)
1*323788f4SGreg Roach<?php
2*323788f4SGreg Roach/**
3*323788f4SGreg Roach * webtrees: online genealogy
4*323788f4SGreg Roach * Copyright (C) 2015 webtrees development team
5*323788f4SGreg Roach * This program is free software: you can redistribute it and/or modify
6*323788f4SGreg Roach * it under the terms of the GNU General Public License as published by
7*323788f4SGreg Roach * the Free Software Foundation, either version 3 of the License, or
8*323788f4SGreg Roach * (at your option) any later version.
9*323788f4SGreg Roach * This program is distributed in the hope that it will be useful,
10*323788f4SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
11*323788f4SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12*323788f4SGreg Roach * GNU General Public License for more details.
13*323788f4SGreg Roach * You should have received a copy of the GNU General Public License
14*323788f4SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
15*323788f4SGreg Roach */
16*323788f4SGreg Roachnamespace Fisharebest\Webtrees\SurnameTradition;
17*323788f4SGreg Roach
18*323788f4SGreg Roach/**
19*323788f4SGreg Roach * Children take a patronym instead of a surname.
20*323788f4SGreg Roach *
21*323788f4SGreg Roach * Sons get their father’s given name plus “sson”
22*323788f4SGreg Roach * Daughters get their father’s given name plus “sdottir”
23*323788f4SGreg Roach */
24*323788f4SGreg Roachclass IcelandicSurnameTradition extends DefaultSurnameTradition implements SurnameTraditionInterface {
25*323788f4SGreg Roach	/**
26*323788f4SGreg Roach	 * What names are given to a new child
27*323788f4SGreg Roach	 *
28*323788f4SGreg Roach	 * @param string $father_name A GEDCOM NAME
29*323788f4SGreg Roach	 * @param string $mother_name A GEDCOM NAME
30*323788f4SGreg Roach	 * @param string $child_sex   M, F or U
31*323788f4SGreg Roach	 *
32*323788f4SGreg Roach	 * @return string[] Associative array of GEDCOM name parts (SURN, _MARNM, etc.)
33*323788f4SGreg Roach	 */
34*323788f4SGreg Roach	public function newChildNames($father_name, $mother_name, $child_sex) {
35*323788f4SGreg Roach		if (preg_match(self::REGEX_GIVN, $father_name, $father_match)) {
36*323788f4SGreg Roach			switch($child_sex) {
37*323788f4SGreg Roach			case 'M':
38*323788f4SGreg Roach				return array(
39*323788f4SGreg Roach					'NAME' => $father_match['GIVN'] . 'sson',
40*323788f4SGreg Roach				);
41*323788f4SGreg Roach			case 'F':
42*323788f4SGreg Roach				return array(
43*323788f4SGreg Roach					'NAME' => $father_match['GIVN'] . 'sdottir',
44*323788f4SGreg Roach				);
45*323788f4SGreg Roach			}
46*323788f4SGreg Roach		}
47*323788f4SGreg Roach
48*323788f4SGreg Roach		return array();
49*323788f4SGreg Roach	}
50*323788f4SGreg Roach
51*323788f4SGreg Roach	/**
52*323788f4SGreg Roach	 * What names are given to a new parent
53*323788f4SGreg Roach	 *
54*323788f4SGreg Roach	 * @param string $child_name A GEDCOM NAME
55*323788f4SGreg Roach	 * @param string $parent_sex M, F or U
56*323788f4SGreg Roach	 *
57*323788f4SGreg Roach	 * @return string[] Associative array of GEDCOM name parts (SURN, _MARNM, etc.)
58*323788f4SGreg Roach	 */
59*323788f4SGreg Roach	public function newParentNames($child_name, $parent_sex) {
60*323788f4SGreg Roach		if ($parent_sex === 'M' && preg_match('~(?<GIVN>[^ /]+)(:?sson|sdottir)$~', $child_name, $child_match)) {
61*323788f4SGreg Roach			return array(
62*323788f4SGreg Roach				'NAME' => $child_match['GIVN'],
63*323788f4SGreg Roach				'GIVN' => $child_match['GIVN'],
64*323788f4SGreg Roach			);
65*323788f4SGreg Roach		} else {
66*323788f4SGreg Roach			return array();
67*323788f4SGreg Roach		}
68*323788f4SGreg Roach	}
69*323788f4SGreg Roach
70*323788f4SGreg Roach	/**
71*323788f4SGreg Roach	 * What names are given to a new spouse
72*323788f4SGreg Roach	 *
73*323788f4SGreg Roach	 * @param string $spouse_name A GEDCOM NAME
74*323788f4SGreg Roach	 * @param string $spouse_sex  M, F or U
75*323788f4SGreg Roach	 *
76*323788f4SGreg Roach	 * @return string[] Associative array of GEDCOM name parts (SURN, _MARNM, etc.)
77*323788f4SGreg Roach	 */
78*323788f4SGreg Roach	public function newSpouseNames($spouse_name, $spouse_sex) {
79*323788f4SGreg Roach		return array();
80*323788f4SGreg Roach	}
81*323788f4SGreg Roach}
82