1323788f4SGreg Roach<?php 23976b470SGreg Roach 3323788f4SGreg Roach/** 4323788f4SGreg Roach * webtrees: online genealogy 589f7189bSGreg Roach * Copyright (C) 2021 webtrees development team 6323788f4SGreg Roach * This program is free software: you can redistribute it and/or modify 7323788f4SGreg Roach * it under the terms of the GNU General Public License as published by 8323788f4SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9323788f4SGreg Roach * (at your option) any later version. 10323788f4SGreg Roach * This program is distributed in the hope that it will be useful, 11323788f4SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12323788f4SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13323788f4SGreg Roach * GNU General Public License for more details. 14323788f4SGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 16323788f4SGreg Roach */ 17fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 20323788f4SGreg Roachnamespace Fisharebest\Webtrees\SurnameTradition; 21323788f4SGreg Roach 22*cb7a42eaSGreg Roachuse Fisharebest\Webtrees\Individual; 23*cb7a42eaSGreg Roach 24323788f4SGreg Roach/** 25323788f4SGreg Roach * Lithuanian — Children take their father’s surname. Wives take their husband’s surname. Surnames are inflected to indicate an individual’s sex and marital status. 26323788f4SGreg Roach */ 275206405dSRico Sonntagclass LithuanianSurnameTradition extends PaternalSurnameTradition 28c1010edaSGreg Roach{ 29e364afe4SGreg Roach // Inflect a surname for wives 30e364afe4SGreg Roach private const INFLECT_WIFE = [ 31323788f4SGreg Roach 'as\b' => 'ienė', 32323788f4SGreg Roach 'is\b' => 'ienė', 33323788f4SGreg Roach 'ys\b' => 'ienė', 34323788f4SGreg Roach 'us\b' => 'ienė', 3513abd6f3SGreg Roach ]; 36323788f4SGreg Roach 37e364afe4SGreg Roach // Inflect a surname for daughters 38e364afe4SGreg Roach private const INFLECT_DAUGHTER = [ 39323788f4SGreg Roach 'a\b' => 'aitė', 40323788f4SGreg Roach 'as\b' => 'aitė', 41323788f4SGreg Roach 'is\b' => 'ytė', 42323788f4SGreg Roach 'ys\b' => 'ytė', 43323788f4SGreg Roach 'ius\b' => 'iūtė', 44323788f4SGreg Roach 'us\b' => 'utė', 4513abd6f3SGreg Roach ]; 46323788f4SGreg Roach 47e364afe4SGreg Roach // Inflect a surname for males 48e364afe4SGreg Roach private const INFLECT_MALE = [ 49323788f4SGreg Roach 'aitė\b' => 'as', 50323788f4SGreg Roach 'ytė\b' => 'is', 51323788f4SGreg Roach 'iūtė\b' => 'ius', 52323788f4SGreg Roach 'utė\b' => 'us', 5313abd6f3SGreg Roach ]; 54323788f4SGreg Roach 55323788f4SGreg Roach /** 56*cb7a42eaSGreg Roach * What name is given to a new child 57323788f4SGreg Roach * 58*cb7a42eaSGreg Roach * @param Individual|null $father 59*cb7a42eaSGreg Roach * @param Individual|null $mother 60*cb7a42eaSGreg Roach * @param string $sex 61323788f4SGreg Roach * 62*cb7a42eaSGreg Roach * @return array<string> 63323788f4SGreg Roach */ 64*cb7a42eaSGreg Roach public function newChildNames(?Individual $father, ?Individual $mother, string $sex): array 65c1010edaSGreg Roach { 66*cb7a42eaSGreg Roach if (preg_match(self::REGEX_SURN, $this->extractName($father), $match)) { 67*cb7a42eaSGreg Roach if ($sex === 'F') { 68*cb7a42eaSGreg Roach $name = $this->inflect($match['NAME'], self::INFLECT_DAUGHTER); 69*cb7a42eaSGreg Roach $surn = $this->inflect($match['SURN'], self::INFLECT_MALE); 70*cb7a42eaSGreg Roach } else { 71*cb7a42eaSGreg Roach $name = $match['NAME']; 72*cb7a42eaSGreg Roach $surn = $match['SURN']; 73323788f4SGreg Roach } 74b2ce94c6SRico Sonntag 7513abd6f3SGreg Roach return [ 76*cb7a42eaSGreg Roach $this->buildName($name, ['TYPE' => 'birth', 'SURN' => $surn]), 77*cb7a42eaSGreg Roach ]; 78*cb7a42eaSGreg Roach } 79*cb7a42eaSGreg Roach 80*cb7a42eaSGreg Roach return [ 81*cb7a42eaSGreg Roach $this->buildName('//', ['TYPE' => 'birth']), 8213abd6f3SGreg Roach ]; 83323788f4SGreg Roach } 84323788f4SGreg Roach 85323788f4SGreg Roach /** 86*cb7a42eaSGreg Roach * What name is given to a new parent 87323788f4SGreg Roach * 88*cb7a42eaSGreg Roach * @param Individual $child 89*cb7a42eaSGreg Roach * @param string $sex 90323788f4SGreg Roach * 91*cb7a42eaSGreg Roach * @return array<string> 92323788f4SGreg Roach */ 93*cb7a42eaSGreg Roach public function newParentNames(Individual $child, string $sex): array 94c1010edaSGreg Roach { 95*cb7a42eaSGreg Roach if ($sex === 'M' && preg_match(self::REGEX_SURN, $this->extractName($child), $match)) { 96*cb7a42eaSGreg Roach $name = $this->inflect($match['NAME'], self::INFLECT_MALE); 97*cb7a42eaSGreg Roach $surn = $this->inflect($match['SURN'], self::INFLECT_MALE); 98*cb7a42eaSGreg Roach 99*cb7a42eaSGreg Roach return [ 100*cb7a42eaSGreg Roach $this->buildName($name, ['TYPE' => 'birth', 'SURN' => $surn]), 101*cb7a42eaSGreg Roach ]; 102b2ce94c6SRico Sonntag } 103b2ce94c6SRico Sonntag 10413abd6f3SGreg Roach return [ 105*cb7a42eaSGreg Roach $this->buildName('//', ['TYPE' => 'birth']), 10613abd6f3SGreg Roach ]; 107323788f4SGreg Roach } 108323788f4SGreg Roach 109323788f4SGreg Roach /** 110323788f4SGreg Roach * What names are given to a new spouse 111323788f4SGreg Roach * 112*cb7a42eaSGreg Roach * @param Individual $spouse 113*cb7a42eaSGreg Roach * @param string $sex 114323788f4SGreg Roach * 115*cb7a42eaSGreg Roach * @return array<string> 116323788f4SGreg Roach */ 117*cb7a42eaSGreg Roach public function newSpouseNames(Individual $spouse, string $sex): array 118c1010edaSGreg Roach { 119*cb7a42eaSGreg Roach if ($sex === 'F' && preg_match(self::REGEX_SURN, $this->extractName($spouse), $match)) { 120*cb7a42eaSGreg Roach $name = $this->inflect($match['NAME'], self::INFLECT_WIFE); 121*cb7a42eaSGreg Roach $surn = $this->inflect($match['SURN'], self::INFLECT_MALE); 122*cb7a42eaSGreg Roach 12313abd6f3SGreg Roach return [ 124*cb7a42eaSGreg Roach $this->buildName('//', ['TYPE' => 'birth']), 125*cb7a42eaSGreg Roach $this->buildName($name, ['TYPE' => 'married', 'SURN' => $surn]), 12613abd6f3SGreg Roach ]; 127b2ce94c6SRico Sonntag } 128b2ce94c6SRico Sonntag 12913abd6f3SGreg Roach return [ 130*cb7a42eaSGreg Roach $this->buildName('//', ['TYPE' => 'birth']), 13113abd6f3SGreg Roach ]; 132323788f4SGreg Roach } 133323788f4SGreg Roach} 134