Skip to content

Commit ec271e2

Browse files
committed
update readme.md
1 parent 5a1184c commit ec271e2

File tree

2 files changed

+300
-10
lines changed

2 files changed

+300
-10
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 (until present) Nima jahan bakhshian
3+
Copyright (c) 2022 (until present) Nima jahan bakhshian nimajahanbakhshian@gmail.com
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 299 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,321 @@ You can install the package via composer:
2020
.....................................
2121
```
2222

23-
## PhpStringHelpers usage
23+
## StrUtility usage
2424

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:
2627

2728
```php
28-
echo .......;
29+
use PhpStringHelpers\utility\StrUtility;
2930
```
3031

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
32187

33-
String helper methods are static so usage is like the following:
34188

35189
```php
36-
echo .......;
190+
StrUtility::rmNumbers(string $string): string
37191
```
38192

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+
```
40330

41331
## Changelog
42332

43333
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
44334

45-
## Security
335+
## issues
46336

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.
48338

49339
## Credits
50340

0 commit comments

Comments
 (0)