xref: /webtrees/app/Elements/FamilyNonEvent.php (revision d11be7027e34e3121be11cc025421873364403f9)
1a2143fbeSGreg Roach<?php
2a2143fbeSGreg Roach
3a2143fbeSGreg Roach/**
4a2143fbeSGreg Roach * webtrees: online genealogy
5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
6a2143fbeSGreg Roach * This program is free software: you can redistribute it and/or modify
7a2143fbeSGreg Roach * it under the terms of the GNU General Public License as published by
8a2143fbeSGreg Roach * the Free Software Foundation, either version 3 of the License, or
9a2143fbeSGreg Roach * (at your option) any later version.
10a2143fbeSGreg Roach * This program is distributed in the hope that it will be useful,
11a2143fbeSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12a2143fbeSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13a2143fbeSGreg Roach * GNU General Public License for more details.
14a2143fbeSGreg Roach * You should have received a copy of the GNU General Public License
15a2143fbeSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
16a2143fbeSGreg Roach */
17a2143fbeSGreg Roach
18a2143fbeSGreg Roachdeclare(strict_types=1);
19a2143fbeSGreg Roach
20a2143fbeSGreg Roachnamespace Fisharebest\Webtrees\Elements;
21a2143fbeSGreg Roach
22a2143fbeSGreg Roachuse Fisharebest\Webtrees\I18N;
23a2143fbeSGreg Roachuse Fisharebest\Webtrees\Registry;
24a2143fbeSGreg Roach
25a2143fbeSGreg Roachuse function strtoupper;
26a2143fbeSGreg Roachuse function uasort;
27a2143fbeSGreg Roach
28a2143fbeSGreg Roach/**
29a2143fbeSGreg Roach * An event which never happened.
30a2143fbeSGreg Roach */
31a2143fbeSGreg Roachclass FamilyNonEvent extends AbstractElement
32a2143fbeSGreg Roach{
33a2143fbeSGreg Roach    protected const SUBTAGS = [
34a2143fbeSGreg Roach        'DATE' => '0:1',
35a2143fbeSGreg Roach        'NOTE' => '0:1',
36a2143fbeSGreg Roach        'SOUR' => '0:1',
37a2143fbeSGreg Roach    ];
38a2143fbeSGreg Roach
39a2143fbeSGreg Roach    /**
40a2143fbeSGreg Roach     * Convert a value to a canonical form.
41a2143fbeSGreg Roach     *
42a2143fbeSGreg Roach     * @param string $value
43a2143fbeSGreg Roach     *
44a2143fbeSGreg Roach     * @return string
45a2143fbeSGreg Roach     */
46a2143fbeSGreg Roach    public function canonical(string $value): string
47a2143fbeSGreg Roach    {
48a2143fbeSGreg Roach        return strtoupper(parent::canonical($value));
49a2143fbeSGreg Roach    }
50a2143fbeSGreg Roach
51a2143fbeSGreg Roach    /**
52a2143fbeSGreg Roach     * A list of controlled values for this element
53a2143fbeSGreg Roach     *
54a2143fbeSGreg Roach     * @return array<int|string,string>
55a2143fbeSGreg Roach     */
56a2143fbeSGreg Roach    public function values(): array
57a2143fbeSGreg Roach    {
58a2143fbeSGreg Roach        $values = [
59a2143fbeSGreg Roach            ''     => '',
60a2143fbeSGreg Roach            'ANUL' => Registry::elementFactory()->make('FAM:ANUL')->label(),
61a2143fbeSGreg Roach            'CENS' => Registry::elementFactory()->make('FAM:CENS')->label(),
62a2143fbeSGreg Roach            'DIV'  => Registry::elementFactory()->make('FAM:DIV')->label(),
63a2143fbeSGreg Roach            'DIVF' => Registry::elementFactory()->make('FAM:DIVF')->label(),
64a2143fbeSGreg Roach            'ENGA' => Registry::elementFactory()->make('FAM:ENGA')->label(),
65a2143fbeSGreg Roach            'MARB' => Registry::elementFactory()->make('FAM:MARB')->label(),
66a2143fbeSGreg Roach            'MARC' => Registry::elementFactory()->make('FAM:MARC')->label(),
67a2143fbeSGreg Roach            'MARL' => Registry::elementFactory()->make('FAM:MARL')->label(),
68a2143fbeSGreg Roach            'MARS' => Registry::elementFactory()->make('FAM:MARS')->label(),
69a2143fbeSGreg Roach            'MARR' => Registry::elementFactory()->make('FAM:MARR')->label(),
70a2143fbeSGreg Roach        ];
71a2143fbeSGreg Roach
72a2143fbeSGreg Roach        uasort($values, I18N::comparator());
73a2143fbeSGreg Roach
74a2143fbeSGreg Roach        return $values;
75a2143fbeSGreg Roach    }
76a2143fbeSGreg Roach}
77