Passed
Push — 2.1 ( ab9191...f7f27f )
by Greg
06:37
created

LanguageDutch::normalizeExceptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * webtrees: online genealogy
5
 * Copyright (C) 2022 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
18
declare(strict_types=1);
19
20
namespace Fisharebest\Webtrees\Module;
21
22
use Fisharebest\Localization\Locale\LocaleInterface;
23
use Fisharebest\Localization\Locale\LocaleNl;
24
use Fisharebest\Webtrees\Encodings\UTF8;
25
26
use function mb_substr;
27
use function str_starts_with;
28
29
/**
30
 * Class LanguageDutch.
31
 */
32
class LanguageDutch extends AbstractModule implements ModuleLanguageInterface
33
{
34
    use ModuleLanguageTrait;
35
36
    /**
37
     * Phone-book ordering of letters.
38
     *
39
     * @return array<int,string>
40
     */
41
    public function alphabet(): array
42
    {
43
        return [
44
            'A',
45
            'B',
46
            'C',
47
            'D',
48
            'E',
49
            'F',
50
            'G',
51
            'H',
52
            'I',
53
            'J',
54
            'K',
55
            'L',
56
            'M',
57
            'N',
58
            'O',
59
            'P',
60
            'Q',
61
            'R',
62
            'S',
63
            'T',
64
            'U',
65
            'V',
66
            'W',
67
            'X',
68
            'Y',
69
            'Z',
70
            'IJ',
71
        ];
72
    }
73
74
    /**
75
     * Some languages use digraphs and trigraphs.
76
     *
77
     * @param string $string
78
     *
79
     * @return string
80
     */
81
    public function initialLetter(string $string): string
82
    {
83
        if (str_starts_with($string, 'IJ')) {
84
            return 'IJ';
85
        }
86
87
        return mb_substr($string, 0, 1);
88
    }
89
90
    /**
91
     * @return LocaleInterface
92
     */
93
    public function locale(): LocaleInterface
94
    {
95
        return new LocaleNl();
96
    }
97
98
    /**
99
     * Letters with diacritics that are considered distinct letters in this language.
100
     *
101
     * @return array<string,string>
102
     */
103
    protected function normalizeExceptions(): array
104
    {
105
        return [
106
            'IJ' => UTF8::LATIN_CAPITAL_LIGATURE_IJ,
107
            'Ij' => UTF8::LATIN_CAPITAL_LIGATURE_IJ,
108
            'ij' => UTF8::LATIN_SMALL_LIGATURE_IJ,
109
            'iJ' => UTF8::LATIN_SMALL_LIGATURE_IJ,
110
        ];
111
    }
112
}
113