xref: /webtrees/app/Contracts/ElementInterface.php (revision b56fa9dd6a5e9075de5337fd34748412e9e559a7)
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     * Create a default value for this element.
40     *
41     * @param Tree $tree
42     *
43     * @return string
44     */
45    public function default(Tree $tree): string;
46
47    /**
48     * An edit control for this data.
49     *
50     * @param string $id
51     * @param string $name
52     * @param string $value
53     * @param Tree   $tree
54     *
55     * @return string
56     */
57    public function edit(string $id, string $name, string $value, Tree $tree): string;
58
59    /**
60     * Escape @ signs in a GEDCOM export.
61     *
62     * @param string $value
63     *
64     * @return string
65     */
66    public function escape(string $value): string;
67
68    /**
69     * Name for this GEDCOM primitive.
70     *
71     * @return string
72     */
73    public function label(): string;
74
75    /**
76     * Create a label/value pair for this element.
77     *
78     * @param string $value
79     * @param Tree   $tree
80     *
81     * @return string
82     */
83    public function labelValue(string $value, Tree $tree): string;
84
85    /**
86     * @param Tree $tree
87     *
88     * @return array<string,string>
89     */
90    public function subtags(Tree $tree): array;
91
92    /**
93     * Display the value of this type of element.
94     *
95     * @param string $value
96     * @param Tree   $tree
97     *
98     * @return string
99     */
100    public function value(string $value, Tree $tree): string;
101
102    /**
103     * A list of controlled values for this element
104     *
105     * @return array<int|string,string>
106     */
107    public function values(): array;
108}
109