Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
stringhelper.php
1
<?php
9
namespace
Bitrix\Main\Text
;
10
16
class
StringHelper
17
{
25
public
static
function
strtoupper
($str)
26
{
27
static
$cache;
28
29
if
(empty($cache[$str]))
30
{
31
$cache[$str] = mb_strtoupper($str);
32
}
33
34
return
$cache[$str];
35
}
36
44
public
static
function
camel2snake
($str)
45
{
46
return
mb_strtolower(preg_replace(
'/(.)([A-Z])/'
,
'$1_$2'
, $str));
47
}
48
56
public
static
function
snake2camel
($str)
57
{
58
$str =
str_replace
(
'_'
,
' '
, mb_strtolower($str));
59
return
str_replace
(
' '
,
''
, ucwords($str));
60
}
61
70
public
static
function
str_replace
($search, $replace, $str)
71
{
72
if
(is_array($str))
73
{
74
foreach
($str as $key => $value)
75
{
76
if
(is_scalar($value))
77
{
78
$str[$key] =
str_replace
($search, $replace, $value);
79
}
80
}
81
}
82
elseif (is_scalar($str))
83
{
84
$str =
str_replace
($search, $replace, $str);
85
}
86
87
return
$str;
88
}
89
96
public
static
function
isStringable
($value): bool
97
{
98
return
!is_array($value)
99
&& (
100
(!is_object($value) && settype($value,
'string'
) !==
false
)
101
|| (is_object($value) && method_exists($value,
'__toString'
))
102
);
103
}
104
}
Bitrix\Main\Text\StringHelper
Definition
stringhelper.php:17
Bitrix\Main\Text\StringHelper\isStringable
static isStringable($value)
Definition
stringhelper.php:96
Bitrix\Main\Text\StringHelper\snake2camel
static snake2camel($str)
Definition
stringhelper.php:56
Bitrix\Main\Text\StringHelper\strtoupper
static strtoupper($str)
Definition
stringhelper.php:25
Bitrix\Main\Text\StringHelper\camel2snake
static camel2snake($str)
Definition
stringhelper.php:44
Bitrix\Main\Text\StringHelper\str_replace
static str_replace($search, $replace, $str)
Definition
stringhelper.php:70
Bitrix\Main\Text
Definition
base32.php:2
modules
main
lib
text
stringhelper.php
Создано системой
1.10.0