1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2021 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\Contracts; 21 22use Fisharebest\Webtrees\Tree; 23 24/** 25 * A GEDCOM element is a tag/primitive in a GEDCOM file. 26 */ 27interface ElementInterface 28{ 29 /** 30 * Convert a value to a canonical form. 31 * 32 * @param string $value 33 * 34 * @return string 35 */ 36 public function canonical(string $value): string; 37 38 /** 39 * Should we collapse the children of this element when editing? 40 * 41 * @return bool 42 */ 43 public function collapseChildren(): bool; 44 45 /** 46 * Create a default value for this element. 47 * 48 * @param Tree $tree 49 * 50 * @return string 51 */ 52 public function default(Tree $tree): string; 53 54 /** 55 * An edit control for this data. 56 * 57 * @param string $id 58 * @param string $name 59 * @param string $value 60 * @param Tree $tree 61 * 62 * @return string 63 */ 64 public function edit(string $id, string $name, string $value, Tree $tree): string; 65 66 /** 67 * Escape @ signs in a GEDCOM export. 68 * 69 * @param string $value 70 * 71 * @return string 72 */ 73 public function escape(string $value): string; 74 75 /** 76 * Name for this GEDCOM primitive. 77 * 78 * @return string 79 */ 80 public function label(): string; 81 82 /** 83 * Create a label/value pair for this element. 84 * 85 * @param string $value 86 * @param Tree $tree 87 * 88 * @return string 89 */ 90 public function labelValue(string $value, Tree $tree): string; 91 92 /** 93 * Set, remove or replace a subtag. 94 * 95 * @param string $subtag 96 * @param string $repeat 97 * @param string $before 98 * 99 * @return void 100 */ 101 public function subtag(string $subtag, string $repeat = '0:1', string $before = ''): void; 102 103 /** 104 * @return array<string,string> 105 */ 106 public function subtags(): array; 107 108 /** 109 * Display the value of this type of element. 110 * 111 * @param string $value 112 * @param Tree $tree 113 * 114 * @return string 115 */ 116 public function value(string $value, Tree $tree): string; 117 118 /** 119 * A list of controlled values for this element 120 * 121 * @return array<int|string,string> 122 */ 123 public function values(): array; 124} 125