1 | <?php |
||
7 | class Str |
||
8 | { |
||
9 | /** |
||
10 | * The cache of snake-cased words. |
||
11 | * |
||
12 | * @var array |
||
13 | */ |
||
14 | protected static $snakeCache = []; |
||
15 | |||
16 | /** |
||
17 | * The cache of camel-cased words. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected static $camelCache = []; |
||
22 | |||
23 | /** |
||
24 | * The cache of studly-cased words. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected static $studlyCache = []; |
||
29 | |||
30 | /** |
||
31 | * Convert a value to camel case. |
||
32 | * |
||
33 | * @param string $value |
||
34 | * |
||
35 | * @return string |
||
36 | */ |
||
37 | public static function camel($value) |
||
45 | |||
46 | /** |
||
47 | * Generate a more truly "random" alpha-numeric string. |
||
48 | * |
||
49 | * @param int $length |
||
50 | * |
||
51 | * @throws \RuntimeException |
||
52 | * |
||
53 | * @return string |
||
54 | */ |
||
55 | public static function random($length = 16) |
||
69 | |||
70 | /** |
||
71 | * Generate a more truly "random" bytes. |
||
72 | * |
||
73 | * @param int $length |
||
74 | * |
||
75 | * @throws RuntimeException |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | public static function randomBytes($length = 16) |
||
94 | |||
95 | /** |
||
96 | * Generate a "random" alpha-numeric string. |
||
97 | * |
||
98 | * Should not be considered sufficient for cryptography, etc. |
||
99 | * |
||
100 | * @param int $length |
||
101 | * |
||
102 | * @return string |
||
103 | */ |
||
104 | public static function quickRandom($length = 16) |
||
110 | |||
111 | /** |
||
112 | * Convert the given string to upper-case. |
||
113 | * |
||
114 | * @param string $value |
||
115 | * |
||
116 | * @return string |
||
117 | */ |
||
118 | public static function upper($value) |
||
122 | |||
123 | /** |
||
124 | * Convert the given string to title case. |
||
125 | * |
||
126 | * @param string $value |
||
127 | * |
||
128 | * @return string |
||
129 | */ |
||
130 | public static function title($value) |
||
134 | |||
135 | /** |
||
136 | * Convert a string to snake case. |
||
137 | * |
||
138 | * @param string $value |
||
139 | * @param string $delimiter |
||
140 | * |
||
141 | * @return string |
||
142 | */ |
||
143 | public static function snake($value, $delimiter = '_') |
||
157 | |||
158 | /** |
||
159 | * Convert a value to studly caps case. |
||
160 | * |
||
161 | * @param string $value |
||
162 | * |
||
163 | * @return string |
||
164 | */ |
||
165 | public static function studly($value) |
||
177 | } |
||
178 |