Issues (2559)

app/Module/LanguageNorwegianBokmal.php (2 issues)

1
<?php
2
3
/**
4
 * webtrees: online genealogy
5
 * Copyright (C) 2025 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\LocaleNb;
24
use Fisharebest\Webtrees\Encodings\UTF8;
0 ignored issues
show
The type Fisharebest\Webtrees\Encodings\UTF8 was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
26
use function mb_substr;
27
use function str_starts_with;
28
29
class LanguageNorwegianBokmal extends AbstractModule implements ModuleLanguageInterface
30
{
31
    use ModuleLanguageTrait;
0 ignored issues
show
The type Fisharebest\Webtrees\Module\ModuleLanguageTrait was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
32
33
    /**
34
     * @return array<int,string>
35
     */
36
    public function alphabet(): array
37
    {
38
        return [
39
            'A',
40
            'B',
41
            'C',
42
            'D',
43
            'E',
44
            'F',
45
            'G',
46
            'H',
47
            'I',
48
            'J',
49
            'K',
50
            'L',
51
            'M',
52
            'N',
53
            'O',
54
            'P',
55
            'Q',
56
            'R',
57
            'S',
58
            'T',
59
            'U',
60
            'V',
61
            'W',
62
            'X',
63
            'Y',
64
            'Z',
65
            UTF8::LATIN_CAPITAL_LETTER_AE,
66
            UTF8::LATIN_CAPITAL_LETTER_O_WITH_STROKE,
67
            UTF8::LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE,
68
        ];
69
    }
70
71
    public function initialLetter(string $string): string
72
    {
73
        if (str_starts_with($string, 'AA')) {
74
            return 'Å';
75
        }
76
77
        return mb_substr($string, 0, 1);
78
    }
79
80
    public function isEnabledByDefault(): bool
81
    {
82
        return false;
83
    }
84
85
    public function locale(): LocaleInterface
86
    {
87
        return new LocaleNb();
88
    }
89
90
    /**
91
     * Letters with diacritics that are considered distinct letters in this language.
92
     *
93
     * @return array<string,string>
94
     */
95
    protected function normalizeExceptions(): array
96
    {
97
        return [
98
            'O' . UTF8::COMBINING_LONG_SOLIDUS_OVERLAY => UTF8::LATIN_CAPITAL_LETTER_O_WITH_STROKE,
99
            'A' . UTF8::COMBINING_RING_ABOVE           => UTF8::LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE,
100
            'AA'                                       => UTF8::LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE,
101
            'Aa'                                       => UTF8::LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE,
102
            'o' . UTF8::COMBINING_LONG_SOLIDUS_OVERLAY => UTF8::LATIN_SMALL_LETTER_O_WITH_STROKE,
103
            'a' . UTF8::COMBINING_RING_ABOVE           => UTF8::LATIN_SMALL_LETTER_A_WITH_RING_ABOVE,
104
            'aa'                                       => UTF8::LATIN_SMALL_LETTER_A_WITH_RING_ABOVE,
105
            'aA'                                       => UTF8::LATIN_SMALL_LETTER_A_WITH_RING_ABOVE,
106
        ];
107
    }
108
}
109