Skip to content

Commit 14fea42

Browse files
update
1 parent be9ba73 commit 14fea42

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

Str.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,19 @@ static public function replaceLast(string $search, string $replace, string $subj
327327
return $subject;
328328
}
329329

330+
/**
331+
* Format Strings with Seperator
332+
*
333+
* @param string $string
334+
* @param int $number
335+
* @param string $seperator
336+
* @return void
337+
*/
338+
static public function formatString($string, $number = 4, $seperator = '-')
339+
{
340+
return implode($seperator, str_split(self::trim($string), $number));
341+
}
342+
330343
/**
331344
* Clean phone string
332345
*

Tests/str.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@
3434

3535

3636
dd(
37-
$changeArrayKeys,
38-
$removeArrayKeys,
37+
// $changeArrayKeys,
38+
// $removeArrayKeys,
3939

4040
Str::convertArrayCase(
4141
data: $arrayCollection,
4242
value: 'lower'
4343
),
4444

45+
Str::formatString('892892982982', 5),
4546
Str::snake('Peterso More'),
4647
Str::camel('peterson more'),
4748
Str::studly('peterson more'),
@@ -53,8 +54,8 @@
5354
Str::randomWords(10),
5455
Str::mask('[email protected]', 2, 'left'),
5556
Str::shorten('【2023最新】香港郵政本地平郵郵費計算、基本郵費一覽', 20),
56-
Str::html('<span class="pul-text pul-text--bold smb-web-view-dynamic-list-item-title">lhkexpressvps.com <script></script></span>'),
57-
Str::text('<span class="pul-text pul-text--bold smb-web-view-dynamic-list-item-title">lhkexpressvps.com <script></script></span>'),
57+
Str::html('<span class="pul-text pul-text--bold smb-web-view-dynamic-list-item-title">google.com <script></script></span>'),
58+
Str::text('<span class="pul-text pul-text--bold smb-web-view-dynamic-list-item-title">google.com <script></script></span>'),
5859
Str::encrypt('hoping for more'),
5960
Str::decrypt('{"k":"dadb5dd1a0558257","e":"7ZMcZv6tALEVq4k7MHpJCQ==","s":"cUFmY0ZwRlpobVJ6bGxTYUJrVDdydz09"}'),
6061
Str::phone('+234 (90) 012-234'),

helpers.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Tamedevelopers\Support\Env;
44
use Tamedevelopers\Support\PDF;
5+
use Tamedevelopers\Support\Str;
56
use Tamedevelopers\Support\Zip;
67
use Tamedevelopers\Support\Hash;
78
use Tamedevelopers\Support\Tame;
@@ -15,6 +16,7 @@
1516
use Tamedevelopers\Support\NumberToWords;
1617
use Tamedevelopers\Support\AutoloadRegister;
1718
use Tamedevelopers\Support\Capsule\FileCache;
19+
use Tamedevelopers\Support\Collections\Collection;
1820

1921

2022
if (! function_exists('AppIsNotCorePHP')) {
@@ -75,6 +77,18 @@ function TameTime($time = null, $timezone = null)
7577
}
7678
}
7779

80+
if (! function_exists('Str')) {
81+
/**
82+
* Str
83+
*
84+
* @return \Tamedevelopers\Support\Str
85+
*/
86+
function Str()
87+
{
88+
return new Str();
89+
}
90+
}
91+
7892
if (! function_exists('TameCountry')) {
7993
/**
8094
* Country Object
@@ -162,6 +176,20 @@ function server()
162176
}
163177
}
164178

179+
if (! function_exists('collect')) {
180+
/**
181+
* Collection of data
182+
*
183+
* @param array $items
184+
*
185+
* @return \Tamedevelopers\Support\Collections\Collection
186+
*/
187+
function collect($items = [])
188+
{
189+
return new Collection($items);
190+
}
191+
}
192+
165193
if (! function_exists('autoload_register')) {
166194
/**
167195
* Autoload function to load class and files in a given folder

0 commit comments

Comments
 (0)