1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
if (!function_exists('tr_strtoupper')) { |
4
|
|
|
function tr_strtoupper(string $value): string |
5
|
|
|
{ |
6
|
|
|
return mb_strtoupper(str_replace('i', 'İ', $value), 'UTF-8'); |
7
|
|
|
} |
8
|
|
|
} |
9
|
|
|
|
10
|
|
|
if (!function_exists('tr_strtolower')) { |
11
|
|
|
function tr_strtolower(string $value): string |
12
|
|
|
{ |
13
|
|
|
return mb_strtolower(str_replace(['İ', 'I'], ['i', 'ı'], $value), 'UTF-8'); |
14
|
|
|
} |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
if (!function_exists('tr_ucfirst')) { |
18
|
|
|
function tr_ucfirst(string $value): string |
19
|
|
|
{ |
20
|
|
|
$tmp = preg_split("//u", $value, 2, PREG_SPLIT_NO_EMPTY); |
21
|
|
|
$more = isset($tmp[1]) ? $tmp[1] : ''; |
22
|
|
|
return mb_convert_case(tr_strtoupper($tmp[0]), MB_CASE_TITLE, 'UTF-8') . tr_strtolower($more); |
23
|
|
|
} |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
if (!function_exists('tr_lcfirst')) { |
27
|
|
|
function tr_lcfirst(string $value): string |
28
|
|
|
{ |
29
|
|
|
$tmp = preg_split("//u", $value, 2, PREG_SPLIT_NO_EMPTY); |
30
|
|
|
$more = isset($tmp[1]) ? $tmp[1] : ''; |
31
|
|
|
return mb_convert_case(tr_strtolower($tmp[0]), MB_CASE_LOWER, 'UTF-8') . $more; |
32
|
|
|
} |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
if (!function_exists('tr_ucwords')) { |
37
|
|
|
function tr_ucwords(string $value): string |
38
|
|
|
{ |
39
|
|
|
$result = ''; |
40
|
|
|
foreach (explode(' ', $value) as $word) { |
41
|
|
|
if ($word === ' ') { |
42
|
|
|
$result .= $word; |
43
|
|
|
} else if (strlen($word) === 0) { |
44
|
|
|
$result .= ' ' . $word; |
45
|
|
|
} else { |
46
|
|
|
$result .= ' ' . tr_ucfirst($word); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
return substr($result, 1); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|