1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2023 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 <https://www.gnu.org/licenses/>. 16 */ 17 18declare(strict_types=1); 19 20namespace Fisharebest\Webtrees\Elements; 21 22use Fisharebest\Webtrees\I18N; 23 24use function strtoupper; 25 26/** 27 * PEDIGREE_LINKAGE_TYPE := {Size=5:7} 28 * [ adopted | birth | foster | sealing ] 29 * A code used to indicate the child to family relationship for pedigree navigation purposes. 30 * Where: 31 * adopted = indicates adoptive parents. 32 * birth = indicates birth parents. 33 * foster = indicates child was included in a foster or guardian family. 34 * sealing = indicates child was sealed to parents other than birth parents. 35 */ 36class PedigreeLinkageType extends AbstractElement 37{ 38 protected const int MAXIMUM_LENGTH = 7; 39 40 public const string VALUE_ADOPTED = 'ADOPTED'; 41 public const string VALUE_BIRTH = 'BIRTH'; 42 public const string VALUE_FOSTER = 'FOSTER'; 43 public const string VALUE_SEALING = 'SEALING'; 44 public const string VALUE_RADA = 'RADA'; 45 46 /** 47 * Convert a value to a canonical form. 48 * 49 * @param string $value 50 * 51 * @return string 52 */ 53 public function canonical(string $value): string 54 { 55 return strtoupper(parent::canonical($value)); 56 } 57 58 /** 59 * A list of controlled values for this element 60 * 61 * @param string $sex the text depends on the sex of the individual 62 * 63 * @return array<int|string,string> 64 */ 65 public function values(string $sex = 'U'): array 66 { 67 $values = [ 68 'M' => [ 69 '' => '', 70 self::VALUE_BIRTH => I18N::translateContext('Male pedigree', 'Birth'), 71 self::VALUE_ADOPTED => I18N::translateContext('Male pedigree', 'Adopted'), 72 self::VALUE_FOSTER => I18N::translateContext('Male pedigree', 'Foster'), 73 /* I18N: “sealing” is a Mormon ceremony. */ 74 self::VALUE_SEALING => I18N::translateContext('Male pedigree', 'Sealing'), 75 /* I18N: “rada” is an Arabic word, pronounced “ra DAH”. It is child-to-parent pedigree, established by wet-nursing. */ 76 self::VALUE_RADA => I18N::translateContext('Male pedigree', 'Rada'), 77 ], 78 'F' => [ 79 '' => '', 80 self::VALUE_BIRTH => I18N::translateContext('Female pedigree', 'Birth'), 81 self::VALUE_ADOPTED => I18N::translateContext('Female pedigree', 'Adopted'), 82 self::VALUE_FOSTER => I18N::translateContext('Female pedigree', 'Foster'), 83 /* I18N: “sealing” is a Mormon ceremony. */ 84 self::VALUE_SEALING => I18N::translateContext('Female pedigree', 'Sealing'), 85 /* I18N: “rada” is an Arabic word, pronounced “ra DAH”. It is child-to-parent pedigree, established by wet-nursing. */ 86 self::VALUE_RADA => I18N::translateContext('Female pedigree', 'Rada'), 87 ], 88 'U' => [ 89 '' => '', 90 self::VALUE_BIRTH => I18N::translateContext('Pedigree', 'Birth'), 91 self::VALUE_ADOPTED => I18N::translateContext('Pedigree', 'Adopted'), 92 self::VALUE_FOSTER => I18N::translateContext('Pedigree', 'Foster'), 93 /* I18N: “sealing” is a Mormon ceremony. */ 94 self::VALUE_SEALING => I18N::translateContext('Pedigree', 'Sealing'), 95 /* I18N: “rada” is an Arabic word, pronounced “ra DAH”. It is child-to-parent pedigree, established by wet-nursing. */ 96 self::VALUE_RADA => I18N::translateContext('Pedigree', 'Rada'), 97 ], 98 ]; 99 100 return $values[$sex] ?? $values['U']; 101 } 102} 103