Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
LanguageTr
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
4
100.00% covered (success)
100.00%
1 / 1
 ucfirst
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
 lcfirst
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2/**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21/**
22 * Turkish (Türkçe)
23 *
24 * The Turkish language, like other Turkic languages, distinguishes
25 * a dotted letter 'i' from a dotless letter 'ı' (U+0131 LATIN SMALL LETTER DOTLESS I).
26 * In these languages, each has an equivalent uppercase mapping:
27 * ı (U+0131 LATIN SMALL LETTER DOTLESS I) -> I (U+0049 LATIN CAPITAL LETTER I),
28 * i (U+0069 LATIN SMALL LETTER I) -> İ (U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE).
29 *
30 * Unicode CaseFolding.txt defines these mappings as type 'T', which means that
31 * they are only for the Turkic languages, tr and az. PHP ignores these mappings,
32 * so we have to override the ucfirst and lcfirst methods.
33 *
34 * See https://en.wikipedia.org/wiki/Dotted_and_dotless_I and T30040
35 *
36 * @ingroup Languages
37 */
38class LanguageTr extends Language {
39
40    private const UC = [ 'I', 'İ' ];
41    private const LC = [ 'ı', 'i' ];
42
43    public function ucfirst( $str ) {
44        $first = mb_substr( $str, 0, 1 );
45        if ( in_array( $first, self::LC ) ) {
46            $first = str_replace( self::LC, self::UC, $first );
47            return $first . mb_substr( $str, 1 );
48        }
49        return parent::ucfirst( $str );
50    }
51
52    public function lcfirst( $str ) {
53        $first = mb_substr( $str, 0, 1 );
54        if ( in_array( $first, self::UC ) ) {
55            $first = str_replace( self::UC, self::LC, $first );
56            return $first . mb_substr( $str, 1 );
57        }
58        return parent::lcfirst( $str );
59    }
60
61}