@@ -20,31 +20,321 @@ You can install the package via composer:
20
20
.....................................
21
21
```
22
22
23
- ## PhpStringHelpers usage
23
+ ## StrUtility usage
24
24
25
- String helper functions are global so usage is like the following:
25
+ String helper methods are static so usage like the following:
26
+ First Using The StrUtility Class:
26
27
27
28
``` php
28
- echo ....... ;
29
+ use PhpStringHelpers\utility\StrUtility ;
29
30
```
30
31
31
- ## StrUtility usage
32
+ <br >
33
+
34
+ - change words to camel case
35
+
36
+ ``` php
37
+ StrUtility::toCamelCase(string $words): string
38
+ ```
39
+
40
+ - change words to pascal case
41
+
42
+ ``` php
43
+ StrUtility::toPascalCase(string $words): string
44
+ ```
45
+
46
+ - change words to kebab case
47
+
48
+ ``` php
49
+ StrUtility::toKebabCase(string $words): string
50
+ ```
51
+
52
+ - change words to title case
53
+
54
+ ``` php
55
+ StrUtility::toTitleCase(string $words): string
56
+ ```
57
+
58
+ - change words to constant case | foo bar baz change to FOO_BAR_BAZ
59
+
60
+ ``` php
61
+ StrUtility::toConstant(string $words): string
62
+ ```
63
+
64
+ - change words to snake case
65
+
66
+ ``` php
67
+ StrUtility::toSnakeCase(string $words): string
68
+ ```
69
+
70
+ - change words to path case | foo bar baz change to foo/bar/baz
71
+
72
+ ``` php
73
+ StrUtility::toPathCase(string $words): string
74
+ ```
75
+
76
+ - change words to ada case | foo bar change to Foo_Bar
77
+
78
+ ``` php
79
+ StrUtility::toAdaCase(string $words): string
80
+ ```
81
+
82
+ - change words to dot notation case | foo bar change to foo.bar
83
+
84
+ ``` php
85
+ StrUtility::dotNotation(string $words): string
86
+ ```
87
+
88
+ - wrapper for htmlspecialchars()
89
+
90
+ ``` php
91
+ StrUtility::entitiesWrapper($data): string
92
+ ```
93
+
94
+ - change string to slug
95
+
96
+ ``` php
97
+ StrUtility::toSlug(string $string): string
98
+ ```
99
+
100
+ - remove all blanks
101
+
102
+ ``` php
103
+ StrUtility::rmAllBlanks(string $string): string
104
+ ```
105
+
106
+ - return alternate string if string param is null
107
+
108
+ ``` php
109
+ StrUtility::alternate(?string $string, string $alternate = null): string
110
+ ```
111
+
112
+ - translation methods, must create lang folder in root of project like lang/\< dirname\>
113
+ translate('app.title') reference to lang/en/app.php and title array key in app.php.
114
+ file app.php must only return associative array.
115
+
116
+ ``` php
117
+ StrUtility::translate(string $key, string $replace = '', string $dirName = 'en'): string
118
+ ```
119
+
120
+ - wrap given string with wrapper param
121
+
122
+ ``` php
123
+ StrUtility::wrapper(int|string $string, int|string $wrapper = '*'): string
124
+ ```
125
+
126
+ - return path of file from root of project
127
+
128
+ ``` php
129
+ StrUtility::filePath(string $path, string $pathExtension = 'php'): string
130
+ ```
131
+
132
+ - generate unique pin numbers between 4 digit and 12 digit
133
+
134
+ ``` php
135
+ StrUtility::generatePin(int $length = 4): int
136
+ ```
137
+
138
+ - clean and safe given string data
139
+
140
+ ``` php
141
+ StrUtility::clearString(string $data): string
142
+ ```
143
+
144
+ - return only string and remove other characters
145
+
146
+ ``` php
147
+ StrUtility::pureString(string $data): string
148
+ ```
149
+
150
+ - generate random string
151
+
152
+ ``` php
153
+ StrUtility::randomChar(int $size = 5): string
154
+ ```
155
+
156
+ - generate random hexadecimal color
157
+
158
+ ``` php
159
+ StrUtility::randomHex(): string
160
+ ```
161
+
162
+ - generate random rgb color
163
+
164
+ ``` php
165
+ StrUtility::randomRgb(): string
166
+ ```
167
+
168
+ - Remove all types of links
169
+
170
+ ``` php
171
+ StrUtility::rmLink(string $string): string
172
+ ```
173
+
174
+ - limit character based on $length and replace theme with ...
175
+
176
+ ``` php
177
+ StrUtility::limitChar(string|int $string, int $length): string
178
+ ```
179
+
180
+ - generate unique id numbers
181
+
182
+ ``` php
183
+ StrUtility::generateId(string|int $prefix ='',string|int $suffix ='',bool $moreEntropy = false): string
184
+ ```
185
+
186
+ - remove all numbers
32
187
33
- String helper methods are static so usage is like the following:
34
188
35
189
``` php
36
- echo .......;
190
+ StrUtility::rmNumbers(string $string): string
37
191
```
38
192
39
- ## Available methods
193
+ - remove all characters
194
+
195
+ ``` php
196
+ StrUtility::rmCharacters(string $string): string
197
+ ```
198
+
199
+ - remove all extra blanks
200
+
201
+ ``` php
202
+ StrUtility::rmExtraBlank(string $string): string
203
+ ```
204
+
205
+ - convert hex color to rgb color
206
+
207
+ ``` php
208
+ StrUtility::hexToRgb(string $color): ?string
209
+ ```
210
+
211
+ - convert rgb color to hex color
212
+
213
+ ``` php
214
+ StrUtility::rgbToHex(string $color): ?string
215
+ ```
216
+
217
+ - generate \< a\> tag link
218
+
219
+ ``` php
220
+ StrUtility::generateAnchor(string|int $content, string $href): string
221
+ ```
222
+
223
+ - return encoding of string . wrapper for mb_detect_encoding()
224
+
225
+ ``` php
226
+ StrUtility::getEncoding(string $string): string
227
+ ```
228
+
229
+ ``` php
230
+ StrUtility::isUtf8(string|array $string): bool
231
+ ```
232
+
233
+ - remove duplicate words
234
+
235
+ ``` php
236
+ StrUtility::rmDuplicateWords(string $string): string
237
+ ```
238
+
239
+ - remove characters from right side based on $num param
240
+
241
+ ``` php
242
+ StrUtility::rmRightChar(string $words, int $num): string
243
+ ```
244
+
245
+ - remove characters from left side based on $num param
246
+
247
+ ``` php
248
+ StrUtility::rmLeftChar(string $words, int $num): string
249
+ ```
250
+
251
+ - remove characters from both side based on $num param
252
+
253
+ ``` php
254
+ StrUtility::rmBothSideChar(string $words, int $num): string
255
+ ```
256
+
257
+ - find whether the type of a data is json
258
+
259
+ ``` php
260
+ StrUtility::isJson(mixed $data): bool
261
+ ```
262
+
263
+ - Checks whether the string contains the specified value or not
264
+
265
+ ``` php
266
+ StrUtility::isContains(string $string, string $search, bool $caseSensitive = false): bool
267
+ ```
268
+
269
+ - Checks whether the string starts with the specified value <$search> or not
270
+
271
+ ``` php
272
+ StrUtility::isStartWith(string $string, string $search, bool $caseSensitive = false): bool
273
+ ```
274
+
275
+ - return the last word
276
+
277
+ ``` php
278
+ StrUtility::lastWord(string $string): string
279
+ ```
280
+
281
+ - return the first word
282
+
283
+ ``` php
284
+ StrUtility::firstWord(string $string): string
285
+ ```
286
+
287
+ - return the first number
288
+
289
+ ``` php
290
+ StrUtility::getFirstNumbers(string $string): string
291
+ ```
292
+
293
+ - return the last number
294
+
295
+ ``` php
296
+ StrUtility::getLastNumbers(string $string): string
297
+ ```
298
+
299
+ ``` php
300
+ StrUtility::rmBeginningNumbers(string $string): string
301
+ ```
302
+
303
+ ``` php
304
+ StrUtility::rmEndingNumbers(string $string): string
305
+ ```
306
+
307
+ ``` php
308
+ StrUtility::convertToUtf8(string $string): string|bool
309
+ ```
310
+
311
+ - incrementing the numbers of the end of the string
312
+
313
+ ``` php
314
+ StrUtility::incrementBy(string $string, ?string $separator = null): string
315
+ ```
316
+
317
+ - decrementing the numbers of the end of the string
318
+
319
+ ``` php
320
+ StrUtility::decrementBy(string $string, ?string $separator = null): string
321
+ ```
322
+
323
+ ## PhpStringHelpers usage
324
+
325
+ String helper functions are global so usage like the following:
326
+
327
+ ``` php
328
+ decrementBy(string $string, ?string $separator = null): string
329
+ ```
40
330
41
331
## Changelog
42
332
43
333
Please see [ CHANGELOG] ( CHANGELOG.md ) for more information what has changed recently.
44
334
45
- ## Security
335
+ ## issues
46
336
47
- If you discover any security related issues, please email nimajahanbakhshian@gmail.com instead of using the issue tracker.
337
+ If you discover any issues, please using the issue tracker.
48
338
49
339
## Credits
50
340
0 commit comments