@@ -109,8 +109,20 @@ StrUtility::rmAllBlanks(string $string): string
109
109
StrUtility::alternate(?string $string, string $alternate = null): string
110
110
```
111
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.
112
+ - translation methods, for using this method you should create a wrapper function
113
+ for example
114
+
115
+ ```
116
+ function <your_wrapper_function_name>(string $key, string $replace = '', string $dirName = 'en')
117
+ {
118
+ $BASE_PATH = // base (root) path of your project
119
+
120
+ $translatePath = StrUtility::translatePath($BASE_PATH, $dirName);
121
+ return StrUtility::translate($translatePath . $key, $replace);
122
+ }
123
+ ```
124
+
125
+ < your_wrapper_function_name>('app.title') reference to lang/en/app.php and title array key in app.php
114
126
file app.php must only return associative array.
115
127
116
128
``` php
@@ -123,7 +135,7 @@ StrUtility::translate(string $key, string $replace = '', string $dirName = 'en')
123
135
StrUtility::wrapper(int|string $string, int|string $wrapper = '*'): string
124
136
```
125
137
126
- - return path of file from root of project
138
+ - return path of file
127
139
128
140
``` php
129
141
StrUtility::filePath(string $path, string $pathExtension = 'php'): string
@@ -320,6 +332,23 @@ StrUtility::incrementBy(string $string, ?string $separator = null): string
320
332
StrUtility::decrementBy(string $string, ?string $separator = null): string
321
333
```
322
334
335
+ - remove last word from given string
336
+
337
+ ``` php
338
+ StrUtility::rmLastWord(string $string): string
339
+ ```
340
+
341
+ - remove first word from given string
342
+
343
+ ``` php
344
+ StrUtility::rmFirstWord(string $string): string
345
+ ```
346
+
347
+ - find whether the type of a given string is slug
348
+
349
+ ``` php
350
+ StrUtility::is_slug(string $slug): bool
351
+ ```
323
352
## PhpStringHelpers usage
324
353
325
354
String helper functions are global so usage like the following:
0 commit comments