xref: /webtrees/app/SurnameTradition/PortugueseSurnameTradition.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 one surname from the mother and one surname from the father.
20*323788f4SGreg Roach *
21*323788f4SGreg Roach * Mother: Maria /AAAA/ /BBBB/
22*323788f4SGreg Roach * Father: Jose  /CCCC/ /DDDD/
23*323788f4SGreg Roach * Child:  Pablo /DDDD/ /BBBB/
24*323788f4SGreg Roach */
25*323788f4SGreg Roachclass PortugueseSurnameTradition extends DefaultSurnameTradition implements SurnameTraditionInterface {
26*323788f4SGreg Roach	/**
27*323788f4SGreg Roach	 * What names are given to a new child
28*323788f4SGreg Roach	 *
29*323788f4SGreg Roach	 * @param string $father_name A GEDCOM NAME
30*323788f4SGreg Roach	 * @param string $mother_name A GEDCOM NAME
31*323788f4SGreg Roach	 * @param string $child_sex   M, F or U
32*323788f4SGreg Roach	 *
33*323788f4SGreg Roach	 * @return string[] Associative array of GEDCOM name parts (SURN, _MARNM, etc.)
34*323788f4SGreg Roach	 */
35*323788f4SGreg Roach	public function newChildNames($father_name, $mother_name, $child_sex) {
36*323788f4SGreg Roach		if (preg_match(self::REGEX_SURNS, $father_name, $match_father)) {
37*323788f4SGreg Roach			$father_surname = $match_father['SURN2'];
38*323788f4SGreg Roach		} else {
39*323788f4SGreg Roach			$father_surname = '';
40*323788f4SGreg Roach		}
41*323788f4SGreg Roach
42*323788f4SGreg Roach		if (preg_match(self::REGEX_SURNS, $mother_name, $match_mother)) {
43*323788f4SGreg Roach			$mother_surname = $match_mother['SURN2'];
44*323788f4SGreg Roach		} else {
45*323788f4SGreg Roach			$mother_surname = '';
46*323788f4SGreg Roach		}
47*323788f4SGreg Roach
48*323788f4SGreg Roach		return array(
49*323788f4SGreg Roach			'NAME' => '/' . $father_surname . '/ /' . $mother_surname . '/',
50*323788f4SGreg Roach			'SURN' => trim($father_surname . ',' . $mother_surname, ','),
51*323788f4SGreg Roach		);
52*323788f4SGreg Roach	}
53*323788f4SGreg Roach
54*323788f4SGreg Roach	/**
55*323788f4SGreg Roach	 * What names are given to a new parent
56*323788f4SGreg Roach	 *
57*323788f4SGreg Roach	 * @param string $child_name A GEDCOM NAME
58*323788f4SGreg Roach	 * @param string $parent_sex M, F or U
59*323788f4SGreg Roach	 *
60*323788f4SGreg Roach	 * @return string[] Associative array of GEDCOM name parts (SURN, _MARNM, etc.)
61*323788f4SGreg Roach	 */
62*323788f4SGreg Roach	public function newParentNames($child_name, $parent_sex) {
63*323788f4SGreg Roach		if (preg_match(self::REGEX_SURNS, $child_name, $match)) {
64*323788f4SGreg Roach			switch($parent_sex) {
65*323788f4SGreg Roach			case 'M':
66*323788f4SGreg Roach				return array(
67*323788f4SGreg Roach					'NAME' => '// /' . $match['SURN1'] . '/',
68*323788f4SGreg Roach					'SURN' => $match['SURN1'],
69*323788f4SGreg Roach				);
70*323788f4SGreg Roach			case 'F':
71*323788f4SGreg Roach				return array(
72*323788f4SGreg Roach					'NAME' => '// /' . $match['SURN2'] . '/',
73*323788f4SGreg Roach					'SURN' => $match['SURN2'],
74*323788f4SGreg Roach				);
75*323788f4SGreg Roach			}
76*323788f4SGreg Roach		}
77*323788f4SGreg Roach
78*323788f4SGreg Roach		return array(
79*323788f4SGreg Roach			'NAME' => '// //'
80*323788f4SGreg Roach		);
81*323788f4SGreg Roach	}
82*323788f4SGreg Roach
83*323788f4SGreg Roach	/**
84*323788f4SGreg Roach	 * What names are given to a new spouse
85*323788f4SGreg Roach	 *
86*323788f4SGreg Roach	 * @param string $spouse_name A GEDCOM NAME
87*323788f4SGreg Roach	 * @param string $spouse_sex  M, F or U
88*323788f4SGreg Roach	 *
89*323788f4SGreg Roach	 * @return string[] Associative array of GEDCOM name parts (SURN, _MARNM, etc.)
90*323788f4SGreg Roach	 */
91*323788f4SGreg Roach	public function newSpouseNames($spouse_name, $spouse_sex) {
92*323788f4SGreg Roach		return array(
93*323788f4SGreg Roach			'NAME' => '// //',
94*323788f4SGreg Roach		);
95*323788f4SGreg Roach	}
96*323788f4SGreg Roach}
97