Skip to content

Commit 454ce43

Browse files
update
1 parent 2d7f16c commit 454ce43

File tree

4 files changed

+147
-51
lines changed

4 files changed

+147
-51
lines changed

Capsule/Manager.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ public static function AppDebug()
127127
public static function isEnvBool($value)
128128
{
129129
if(is_string($value)){
130-
return Str::lower($value) === 'true'
131-
? true
132-
: false;
130+
return Str::lower($value) === 'true';
133131
}
134132

135133
return $value;

README.md

Lines changed: 125 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Support Package For PHP and Laravel
1010
* [Installation](#installation)
1111
* [All Paths](#all-paths)
1212
* [Number to Words](#number-to-words)
13-
* [Iso](#iso)
13+
* [ISO](#iso)
1414
* [Cents](#Cents)
1515
* [Value](#value)
1616
* [toText](#toText)
@@ -49,10 +49,36 @@ Support Package For PHP and Laravel
4949
* [exceptArray](#exceptArray)
5050
* [replaceFirst](#replaceFirst)
5151
* [replaceLast](#replaceLast)
52-
* [removeKeysFromArray](#removeKeysFromArray)
53-
* [changeKeysFromArray](#changeKeysFromArray)
54-
* [convertArrayKey](#convertArrayKey)
52+
* [renameArrayKeys](#renameArrayKeys)
53+
* [forgetArrayKeys](#forgetArrayKeys)
54+
* [changeKeyCase](#changeKeyCase)
5555
* [convertArrayCase](#convertArrayCase)
56+
* [padLeft](#padLeft)
57+
* [padRight](#padRight)
58+
* [words](#words)
59+
* [ascii](#ascii)
60+
* [is](#is)
61+
* [snake](#snake)
62+
* [camel](#camel)
63+
* [kebab](#kebab)
64+
* [title](#title)
65+
* [studly](#studly)
66+
* [slugify](#slugify)
67+
* [slug](#slug)
68+
* [before](#before)
69+
* [after](#after)
70+
* [between](#between)
71+
* [contains](#contains)
72+
* [truncate](#truncate)
73+
* [reverse](#reverse)
74+
* [count](#count)
75+
* [countOccurrences](#countOccurrences)
76+
* [uuid](#uuid)
77+
* [randomWords](#randomWords)
78+
* [extension](#extension)
79+
* [wrap](#wrap)
80+
* [head](#head)
81+
* [last](#last)
5682
* [Country](#country)
5783
* [Usage](#country-usage)
5884
* [iso3](#country-iso3)
@@ -185,7 +211,7 @@ Support Package For PHP and Laravel
185211
* [PDF](#pdf)
186212
* [Read PDF](#read-pdf)
187213
* [Time](#time)
188-
* [time-data](#time-data)
214+
* [time-usage](#time-usage)
189215
* [now](#now)
190216
* [date](#date)
191217
* [today](#today)
@@ -509,25 +535,95 @@ Tame()->formatNumberToNearestThousand(1500000);
509535

510536
### Str Usage
511537

512-
### Methods
513-
- replaceFirst · replaceLast · words · ascii · padLeft · is · exceptArray · convertArrayCase · flattenValue · bindings · formatString · formatOnlyString · phone · mask · html · text · shorten · random
514-
515538
```php
516539
use Tamedevelopers\Support\Str;
517540

518-
// Quick examples
519-
Str::replaceFirst('foo', 'bar', 'foofoo'); // 'barfoo'
520-
Str::words('The quick brown fox jumps', 3); // 'The quick brown...'
521-
Str::ascii('Jürgen'); // 'Jurgen'
522-
Str::padLeft('7', 3, '0'); // '007'
523-
Str::is('user/*', 'user/42'); // true
524-
Str::exceptArray(['a'=>1,'b'=>2], 'a'); // ['b'=>2]
525-
Str::convertArrayCase(['Name' => ['Age' => 1]], 'lower', 'upper'); // ['name' => ['age' => 1]]
541+
// Replace first/last occurrence
542+
Str::replaceFirst('foo', 'bar', 'foofoo'); // 'barfoo'
543+
Str::replaceLast('foo', 'bar', 'foofoo'); // 'foobar'
544+
545+
// Word limiting & ASCII
546+
Str::words('The quick brown fox jumps', 3); // 'The quick brown...'
547+
Str::ascii('Jürgen'); // 'Jurgen'
548+
549+
// Padding
550+
Str::padLeft('7', 3, '0'); // '007'
551+
Str::padRight('7', 3, '0'); // '700'
552+
553+
// Pattern matching
554+
Str::is('user/*', 'user/42'); // true
555+
Str::contains('brown', 'The quick brown fox'); // true
556+
557+
// Case/format helpers
558+
Str::snake('Hello World'); // 'hello_world'
559+
Str::camel('hello world'); // 'helloWorld'
560+
Str::kebab('Hello World'); // 'hello-world'
561+
Str::title('hello world'); // 'Hello World'
562+
Str::studly('hello world'); // 'HelloWorld'
563+
Str::slug('Hello World!'); // 'hello-world'
564+
Str::slugify('À bientôt'); // 'a-bientot'
565+
566+
// Slicing
567+
Str::before('user:42', ':'); // 'user'
568+
Str::after('user:42', ':'); // '42'
569+
Str::between('a[core]z', '[', ']'); // 'core'
570+
571+
// Transformations
572+
Str::reverse('abc'); // 'cba'
573+
Str::truncate('lorem ipsum', 5); // 'lo...'
574+
575+
// Randoms
576+
Str::random(8); // 'a1B9...'
577+
Str::uuid(); // 'xxxxxxxx-xxxx-4xxx-...'
578+
Str::randomWords(3); // 'lor em ip'
579+
580+
// Arrays
581+
Str::exceptArray(['a'=>1,'b'=>2], 'a'); // ['b'=>2]
582+
Str::renameArrayKeys([['id'=>1]], 'id', 'user_id');// [['user_id'=>1]]
583+
Str::forgetArrayKeys(['a'=>1,'b'=>2], 'a'); // ['b'=>2]
584+
Str::bindings(['where'=>[1,2], 'join'=>[3]]); // [1,2,3]
585+
Str::flattenValue([[1,2],[3]]); // [1,2,3]
586+
Str::convertArrayCase(['Name'=>['Age'=>1]], 'lower', 'upper'); // ['name'=>['age'=>1]]
587+
588+
// Security/text helpers
589+
Str::phone('+1 (555) 123-4567'); // '+15551234567'
590+
Str::mask('1234567890', 4, 'right'); // '******7890'
591+
Str::html('&lt;b&gt;Hi&lt;/b&gt;'); // '<b>Hi</b>'
592+
Str::text('<b>Hi</b>'); // 'Hi'
593+
Str::shorten('Long sentence here', 10); // 'Long sente...'
594+
Str::encrypt('secret'); // encrypted
595+
Str::decrypt('...'); // original
596+
```
597+
598+
## Country
599+
- Country data and helpers
600+
- Class: `Tamedevelopers\Support\Country`
601+
- It's helper class can be called, using -- `TameCountry()`
602+
603+
### Country Usage
604+
605+
- ISO codes and flags
606+
```php
607+
use Tamedevelopers\Support\Country;
608+
609+
Country::getCountryIso3('name');
610+
Country::getCountryIso2('name');
611+
Country::getCountryFlagIso3('name');
612+
Country::getCountryFlagIso2('name');
613+
```
614+
615+
- Months, Weeks, Time Zones, Captcha Locale
616+
```php
617+
Country::getMonths('short');
618+
Country::getWeeks('mon');
619+
Country::getTimeZone('Europe/London');
620+
Country::getCaptchaLocale('en');
526621
```
527622

528623
## File
529624
- The Core File utilities (read, write, copy, move, info).
530625
- Class: `Tamedevelopers\Support\Capsule\File`
626+
- It's helper class can be called, using -- `TameFile()`
531627

532628
### File Usage
533629

@@ -688,6 +784,7 @@ TameZip()->download('newData.zip')
688784

689785
## PDF
690786
- Require package to be installed - `composer require dompdf/dompdf`
787+
- It's helper class can be called, using -- `TamePDF()`
691788

692789
| options | Description |
693790
|----------------------- |-----------------------|
@@ -713,14 +810,6 @@ PDF::create([
713810
'output' => 'view',
714811
]);
715812
```
716-
- or -- `Helpers Function`
717-
```
718-
TamePDF()->create([
719-
'content' => '<h1>Hello World!</h1>',
720-
'destination' => public_path("invoice/{$generate}"),
721-
'output' => 'save',
722-
]);
723-
```
724813

725814
### Read PDF
726815
- Takes one param as `string`
@@ -733,16 +822,10 @@ This will read the PDF to the browser
733822
```
734823

735824
## Time
736-
- Helper function is called using `TameTime()`
737-
- Visit the Tests/ folder to see more examples.
825+
- Class: `\Tamedevelopers\Support\Time`
826+
- It's helper class can be called, using -- `TameTime()`
738827

739-
```
740-
use Tamedevelopers\Support\Time;
741-
742-
$time = new Time('now', 'Africa/Lagos');
743-
```
744-
745-
### time-data
828+
### Time Usage
746829
- Get time date from class
747830

748831
| function name | Description |
@@ -757,6 +840,8 @@ $time = new Time('now', 'Africa/Lagos');
757840
| `time() \| getTime()` | Get time as int |
758841

759842
```
843+
$time = new Time('now', 'Africa/Lagos');
844+
760845
[
761846
$time4->time(),
762847
$time4->sec(),
@@ -927,6 +1012,8 @@ Time::getTimeZone();
9271012
```
9281013

9291014
## Cookie
1015+
- Class: `\Tamedevelopers\Support\Cookie`
1016+
- It's helper class can be called, using -- `TameCookie()`
9301017

9311018
### Cookie Usage
9321019

@@ -950,7 +1037,7 @@ Time::getTimeZone();
9501037
- [optional] `$secure` param as `bool | null`
9511038
- [optional] `$httponly` param as `bool | null`
9521039

953-
```
1040+
```php
9541041
use Tamedevelopers\Support\Cookie;
9551042

9561043
Cookie::set('cookie_name', 'value');
@@ -959,7 +1046,7 @@ Cookie::set('cookie_name', 'value');
9591046
### Get
9601047
- Takes param as `string`
9611048

962-
```
1049+
```php
9631050
Cookie::get('cookie_name');
9641051
```
9651052

@@ -969,22 +1056,22 @@ Cookie::get('cookie_name');
9691056
- [optional] `$path` param as `string | null`
9701057
- [optional] `$domain` param as `string | null`
9711058

972-
```
1059+
```php
9731060
Cookie::forget('cookie_name');
9741061
```
9751062

9761063
### Has
9771064
- Takes param as `string`
9781065
- Returns `bool`
9791066

980-
```
1067+
```php
9811068
if(Cookie::has('cookie_name')){
9821069
// execute code
9831070
}
9841071
```
9851072

9861073
- or -- `Helpers Function`
987-
```
1074+
```php
9881075
TameCookie()->set('user', '__user');
9891076
```
9901077

Str.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Tamedevelopers\Support;
66

7-
use Tamedevelopers\Support\Server;
87
use Tamedevelopers\Support\Traits\StrTrait;
98

109
class Str

helpers.php

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Tamedevelopers\Support\Country;
1616
use Tamedevelopers\Support\UrlHelper;
1717
use Tamedevelopers\Support\Translator;
18+
use Tamedevelopers\Support\Capsule\File;
1819
use Tamedevelopers\Support\NumberToWords;
1920
use Tamedevelopers\Support\AutoloadRegister;
2021
use Tamedevelopers\Support\Capsule\FileCache;
@@ -68,7 +69,7 @@ function TameMail()
6869

6970
if (! function_exists('TameEnv')) {
7071
/**
71-
* Env Object
72+
* Env Class
7273
* @param mixed $path
7374
* @return \Tamedevelopers\Support\Env
7475
*/
@@ -78,9 +79,20 @@ function TameEnv($path = null)
7879
}
7980
}
8081

82+
if (! function_exists('TameFile')) {
83+
/**
84+
* File Class
85+
* @return \Tamedevelopers\Support\Capsule\File
86+
*/
87+
function TameFile()
88+
{
89+
return new File();
90+
}
91+
}
92+
8193
if (! function_exists('TameCookie')) {
8294
/**
83-
* Cookie Object
95+
* Cookie Class
8496
*
8597
* @return \Tamedevelopers\Support\Cookie
8698
*/
@@ -92,7 +104,7 @@ function TameCookie()
92104

93105
if (! function_exists('TameTime')) {
94106
/**
95-
* Time Object
107+
* Time Class
96108
* @param int|string|null $time
97109
* @param string|null $timezone
98110
* @return \Tamedevelopers\Support\Time
@@ -106,7 +118,7 @@ function TameTime($time = null, $timezone = null)
106118

107119
if (! function_exists('TameCollect')) {
108120
/**
109-
* Collection of data
121+
* Collection Class
110122
*
111123
* @param array $items
112124
*
@@ -120,7 +132,7 @@ function TameCollect($items = [])
120132

121133
if (! function_exists('tcollect')) {
122134
/**
123-
* Collection of data
135+
* Collection Class
124136
*
125137
* @param array $items
126138
*
@@ -146,7 +158,7 @@ function TameStr()
146158

147159
if (! function_exists('TameCountry')) {
148160
/**
149-
* Country Object
161+
* Country Class
150162
* @return \Tamedevelopers\Support\Country
151163
*/
152164
function TameCountry()
@@ -157,7 +169,7 @@ function TameCountry()
157169

158170
if (! function_exists('NumberToWords')) {
159171
/**
160-
* NumberToWords Object
172+
* NumberToWords Class
161173
* @return \Tamedevelopers\Support\NumberToWords
162174
*/
163175
function NumberToWords()
@@ -168,7 +180,7 @@ function NumberToWords()
168180

169181
if (! function_exists('TamePDF')) {
170182
/**
171-
* PDF Object
183+
* PDF Class
172184
*
173185
* @return \Tamedevelopers\Support\PDF
174186
*/
@@ -180,7 +192,7 @@ function TamePDF()
180192

181193
if (! function_exists('TameZip')) {
182194
/**
183-
* Zip Object
195+
* Zip Class
184196
*
185197
* @return \Tamedevelopers\Support\Zip
186198
*/

0 commit comments

Comments
 (0)