Skip to content

Commit d65a92d

Browse files
UPDATE
1 parent e0226a5 commit d65a92d

File tree

4 files changed

+222
-73
lines changed

4 files changed

+222
-73
lines changed

README.md

Lines changed: 94 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,24 @@ Support Package For Tamedevelopers
99
* [Number to Words](#number-to-words)
1010
* [Tame](#tame)
1111
* [byteToUnit](#byteToUnit)
12-
* [sizeToBytes](#sizeToBytes)
12+
* [unitToByte](#unitToByte)
1313
* [fileTime](#fileTime)
1414
* [exists](#exists)
1515
* [unlink](#unlink)
16+
* [mask](#mask)
17+
* [imageToBase64](#imageToBase64)
18+
* [emailValidator](#emailValidator)
19+
* [platformIcon](#platformIcon)
20+
* [paymentIcon](#paymentIcon)
1621
* [calPercentageBetweenNumbers](#calPercentageBetweenNumbers)
1722
* [formatNumberToNearestThousand](#formatNumberToNearestThousand)
1823
* [calculateVolumeWeight](#calculateVolumeWeight)
1924
* [calculateCubicMeterWeight](#calculateCubicMeterWeight)
2025
* [getBetweenBoxLengthAndWeightInKg](#getBetweenBoxLengthAndWeightInKg)
2126
* [getBetweenBoxLengthAndWeightInCMB](#getBetweenBoxLengthAndWeightInCMB)
27+
* [Str](#str)
28+
* [byteToUnit](#byteToUnit)
29+
* [sizeToBytes](#sizeToBytes)
2230
* [Zip](#zip)
2331
* [Unzip](#unzip)
2432
* [Zip Download](#zip-download)
@@ -61,7 +69,7 @@ composer require tamedevelopers/support
6169
| function name | Description |
6270
|---------------------------|-----------------------------------------------|
6371
| base_path() | Get absolute base directory path. Accepts a param `string` if given, and append to path |
64-
| directory() | Same as `base_path()` |
72+
| directory() | Thesame as `base_path()` |
6573
| public_path() | Root/public path. Accepts a param `string` if given, and append to path |
6674
| storage_path() | Root/storage path. Accepts a param `string` if given, and append to path |
6775
| app_path() | Root/app path. Accepts a param `string` if given, and append to path |
@@ -78,7 +86,7 @@ composer require tamedevelopers/support
7886

7987
| iso (country iso3) | cents | number |
8088
|----------------------------|-------|--------|
81-
| `AFG \| NGA \| GBR \| USA `| `true \| false` | `int\|float\|string` |
89+
| `NGA \| GBR \| USA `| `true \| false` | `int\|float\|string` |
8290
| If `iso` is given and found, it'll automatically converts the text into a currency format | If you want the decimals to be translated to text as well. | numeric figures: `299 \| '42,982' \| 3200.98` |
8391

8492

@@ -99,15 +107,15 @@ NumberToWords::cents(true);
99107

100108
### Value
101109
- Takes one param as `int | float | string`
102-
- If numbers is larger than a trillion `1_000_000_000_000`, the value must be passed as a string.
110+
- If numbers is larger than a trillion `1_000_000_000_000`, then the value must be passed as a string.
103111

104112
```
105113
NumberToWords::value(1290);
106114
```
107115

108-
### Usage `toText()`
116+
### Usage -- `toText()`
109117
- Convert number to readable words
110-
- Here we're using the function helper method
118+
- Below, we're using the function helper method
111119
```
112120
NumberToWords()
113121
->iso('TUR')
@@ -118,7 +126,7 @@ NumberToWords()
118126
// One hundred and twenty lira, nine hundred and fifty-three kuruş
119127
```
120128

121-
### Usage `toNumber()`
129+
### Usage -- `toNumber()`
122130
- Convert words to number
123131
- comma `, ` is used to seperate decimals in words
124132
```
@@ -134,12 +142,10 @@ NumberToWords::value('twelve million three hundred thousand, six hundred and nin
134142

135143
## Tame
136144
- The Core Class of Components
137-
- It's helper class can be called as -- `Tame()`
145+
- It's helper class can be called, using -- `Tame()`
138146

139147
```
140148
Tamedevelopers\Support\Tame
141-
142-
Tame::fileTime('absolute_path_to_file');
143149
```
144150

145151
### byteToUnit
@@ -157,15 +163,15 @@ Tame::fileTime('absolute_path_to_file');
157163
```
158164
Tame()->byteToUnit(6880);
159165
160-
// 7kb
166+
// Output: 7kb
161167
```
162168

163-
### sizeToBytes
169+
### unitToByte
164170

165171
```
166-
Tame()->sizeToBytes('24mb');
172+
Tame()->unitToByte('24mb');
167173
168-
// 25165824
174+
// Output: 25165824
169175
```
170176

171177
### fileTime
@@ -191,6 +197,80 @@ Tame()->exists(base_path('filepath.php'));
191197
Tame()->unlink(base_path('path/to/directory/avatar.png'), 'default.png');
192198
```
193199

200+
### mask
201+
- Masks characters in a string based on position and length, with support for emails and custom masking characters.
202+
203+
| Params | Description |
204+
|---------------|-----------------------------------------------------------------------------------------------|
205+
| `$str` | The string to be masked. |
206+
| `$length` | The number of characters to mask (default is 4). |
207+
| `$position` | The position to apply the mask: `'left'`, `'center'`, or `'right'` (default is `'right'`). |
208+
| `$mask` | The character used for masking (default is `*`). |
209+
210+
#### Example:
211+
```
212+
Tame()->mask('[email protected]', 4, 'left');
213+
// Output: "****[email protected]"
214+
215+
Tame()->mask('[email protected]', 4, 'right');
216+
// Output: "exa****@email.com"
217+
218+
Tame()->mask('shortstring', 4, 'center');
219+
// Output: "sho****ing"
220+
```
221+
222+
### imageToBase64
223+
- Converts an image file to its Base64 representation. Supports local files and direct URLs - `null|string`
224+
225+
```
226+
Tame()->imageToBase64(base_path('path/to/image.jpg'));
227+
// Output: "data:image/jpg;base64,..." (Base64 string for the image)
228+
229+
230+
Tame()->imageToBase64('https://example.com/image.png', true);
231+
// Output: "data:image/png;base64,..." (Base64 string for the URL image)
232+
```
233+
234+
### emailValidator
235+
- Validates an email address with optional domain and server verification - `bool`
236+
237+
| Params | Description |
238+
|----------------|---------------------------------------------------------------------------------------------------------------|
239+
| email | The email address to validate. |
240+
| use_internet | By default is set to `false`. If `true`, checks the domain using DNS (`checkdnsrr()` and `getmxrr()`) for validity. If `false`, skips domain validation (default: `false`). |
241+
| server_verify | Verifies the mail server by checking MX records (default: `false`). Only used if `use_internet` is `true`. |
242+
243+
```
244+
Tame()->emailValidator('[email protected]');
245+
// Output: true (Valid email with domain check using DNS)
246+
247+
248+
Tame()->emailValidator('[email protected]', false);
249+
// Output: true (Valid format only, no internet or DNS checks)
250+
251+
Tame()->emailValidator('[email protected]', true, true);
252+
// Output: true or false (Valid format with domain and server verification)
253+
```
254+
255+
### platformIcon
256+
257+
### platformIcon
258+
- Returns the path to the SVG icon for the specified platform or operating system.
259+
260+
| Params |Description |
261+
|--------------|-----------------------------|
262+
| `$platform` | Platform name (e.g., `'windows'`, `'linux'`, `android`, `'iphone'`, `'mac'`, etc.) |
263+
| `$os_name` | OS name (e.g., `'macos'`, `'os x'`, `'ios'`) |
264+
265+
#### Example
266+
267+
```php
268+
$platform = Tame()->platformIcon('windows');
269+
// Output: /path/to/icons/platform/windows.svg
270+
271+
include $platform;
272+
```
273+
194274
### calPercentageBetweenNumbers
195275
- Calculates the percentage relationship between two numbers as an - `int`
196276

0 commit comments

Comments
 (0)