Skip to content

Commit c657005

Browse files
author
Fredrick Peter
committed
support updgrade
1 parent c4a1105 commit c657005

File tree

13 files changed

+1994
-1407
lines changed

13 files changed

+1994
-1407
lines changed

Country.php

Lines changed: 54 additions & 1184 deletions
Large diffs are not rendered by default.

Env.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,12 @@ public static function env(?string $key = null, mixed $value = null)
244244
* Update Environment path .env file
245245
* @param string $key \Environment key you want to update
246246
* @param string|bool $value \Value allocated to the key
247-
* @param bool $allow_quote \Allow quotes around value
248-
* @param bool $allow_space \Allow space between key and value
247+
* @param bool $quote \Allow quotes around value
248+
* @param bool $space \Allow space between key and value
249249
*
250250
* @return bool
251251
*/
252-
public static function updateENV(?string $key = null, string|bool $value = null, ?bool $allow_quote = true, ?bool $allow_space = false)
252+
public static function updateENV(?string $key = null, string|bool $value = null, ?bool $quote = true, ?bool $space = false)
253253
{
254254
$path = self::formatWithBaseDirectory('.env');
255255

@@ -267,15 +267,15 @@ public static function updateENV(?string $key = null, string|bool $value = null,
267267
if (strpos($line, $key) === 0) {
268268

269269
// get space seperator value
270-
$separator = $allow_space ? " = " : "=";
270+
$separator = $space ? " = " : "=";
271271

272272
// check for boolean value
273273
if(is_bool($value)){
274274
// Update the value of the variable
275275
$line = "{$key}=" . ($value ? 'true' : 'false') . PHP_EOL;
276276
}else{
277277
// check if quote is allowed
278-
if($allow_quote){
278+
if($quote){
279279
// Update the value of the variable with quotes
280280
$line = "{$key}{$separator}\"{$value}\"" . PHP_EOL;
281281
}else{

Hash.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ final class Hash {
2424
static public function make($password)
2525
{
2626
// Check if the password exceeds the maximum length
27-
if (mb_strlen($password, 'UTF-8') > 72) {
28-
self::passwordLengthVerifier($password, 72);
29-
}
27+
self::passwordLengthVerifier($password, 72);
3028

3129
// Hash the password using bcrypt with the generated salt
3230
return password_hash($password, PASSWORD_BCRYPT, ['cost' => 10]);
@@ -57,7 +55,7 @@ static public function check($newPassword, $oldHashedPassword)
5755
* @param mixed $maxPasswordLength
5856
* @return void
5957
*/
60-
static private function passwordLengthVerifier($password, $maxPasswordLength = 10)
58+
static private function passwordLengthVerifier($password, $maxPasswordLength = 72)
6159
{
6260
try {
6361
if (mb_strlen($password, 'UTF-8') > $maxPasswordLength) {

Tame.php

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use ZipArchive;
88
use Tamedevelopers\Support\Str;
9-
use Tamedevelopers\Support\Time;
109
use Tamedevelopers\Support\Server;
1110
use Tamedevelopers\Support\Traits\TameTrait;
1211

@@ -58,7 +57,7 @@ class Tame{
5857
* @param mixed $message
5958
* @return mixed
6059
*/
61-
static public function echoJson(int $response = 0, string $message = 'null')
60+
static public function echoJson(int $response = 0, $message = null)
6261
{
6362
echo json_encode(['response' => $response, 'message' => $message]);
6463
}
@@ -94,51 +93,6 @@ static public function versionCompare($version)
9493
return false;
9594
}
9695

97-
/**
98-
* Instance of Time
99-
* @param string|null $time
100-
* @param string|null $timezone
101-
*
102-
* @return \Tamedevelopers\Support\Time
103-
*/
104-
static public function time(?string $time = 'now', ?string $timezone = 'UTC')
105-
{
106-
return new Time($time, $timezone);
107-
}
108-
109-
/**
110-
* Create timestamp
111-
*
112-
* @param mixed $date
113-
* - string|int|float
114-
*
115-
* @param string $format
116-
* - Your defined format type i.e: Y-m-d H:i:s a
117-
* - Converted TimeStamp
118-
*
119-
* @return string
120-
*/
121-
static public function timestamp($date, ?string $format = "Y-m-d H:i:s")
122-
{
123-
if(is_string($date)){
124-
$date = strtotime($date);
125-
}
126-
return date($format, $date);
127-
}
128-
129-
/**
130-
* Create Javascript timer
131-
*
132-
* @param mixed $time
133-
* - Converted TimeStamp
134-
*
135-
* @return string
136-
*/
137-
static public function javascriptTimer($time)
138-
{
139-
return self::timestamp($time, 'M j, Y H:i:s');
140-
}
141-
14296
/**
14397
* Check if headers have been sent.
14498
* This function checks if headers have been sent and outputs information about where headers were sent.

Tests/country.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
use Tamedevelopers\Support\Country;
4+
5+
require_once __DIR__ . '/../vendor/autoload.php';
6+
7+
8+
// helper function
9+
// country();
10+
11+
// Country::countryIso3()
12+
13+
dd(
14+
15+
country()->getTimeZone("Africa/Addis_Ababa"),
16+
17+
country()->getCaptchaLocale('ar'),
18+
19+
Country::getCountryIso3('NGA')
20+
);

Tests/password.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
use Tamedevelopers\Support\Hash;
4+
5+
require_once __DIR__ . '/../vendor/autoload.php';
6+
7+
8+
// bcrypt('testPassword')
9+
// Hash::make('testPassword')
10+
// $2y$10$Frh7yG3.qnGdQ9Hd8OK/y.aBWXFLiFD3IWqUjIWWodUhzIVF3DpT6 --- testPassword
11+
12+
// Hash::check('testPassword', '$2y$10$7a90e2de3f5383819f812u2GwVuprKTsAW7IfeskSkn6/Ky9vSQ.2')
13+
14+
15+
dd(
16+
Hash::make('testPassword'),
17+
18+
bcrypt('testPassword'),
19+
20+
Hash::check('testPassword', '$2y$10$Frh7yG3.qnGdQ9Hd8OK/y.aBWXFLiFD3IWqUjIWWodUhzIVF3DpT6')
21+
);
22+

Tests/test.php

Lines changed: 7 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
<?php
22

33
use Tamedevelopers\Support\Env;
4-
use Tamedevelopers\Support\Hash;
4+
use Tamedevelopers\Support\PDF;
55
use Tamedevelopers\Support\Tame;
6-
use Tamedevelopers\Support\Server;
76
use Tamedevelopers\Support\Slugify;
8-
use Tamedevelopers\Support\Translator;
9-
use Tamedevelopers\Support\Capsule\Forge;
107

118
require_once __DIR__ . '/../vendor/autoload.php';
129

1310

14-
// $Json = '{"name":"Peterson","age":20,"food":["Rice","Garri","Fish","Calories"]}';
11+
$Json = '{"name":"Peterson","age":20,"food":["Rice","Garri","Fish","Calories"]}';
1512

1613
// Env::loadOrFail();
1714

18-
// server()->toArray($Json);
19-
// to_object($Json);
20-
2115

2216
// PDF()->create([
2317
// 'content' => "<h1>Title First</h1> <br> Hello There i Love You!",
@@ -38,12 +32,6 @@
3832
// Tame::include('normal.php');
3933
// Tame()->include('normal.php');
4034

41-
// bcrypt('testPassword')
42-
// Hash::make('testPassword')
43-
// $2y$10$Frh7yG3.qnGdQ9Hd8OK/y.aBWXFLiFD3IWqUjIWWodUhzIVF3DpT6 --- testPassword
44-
45-
// Hash::check('testPassword', '$2y$10$7a90e2de3f5383819f812u2GwVuprKTsAW7IfeskSkn6/Ky9vSQ.2')
46-
4735
// Slugify::slug('Hottest Product 2023, For Health Benefits');
4836

4937
// Server::createTemplateFile([
@@ -61,46 +49,11 @@
6149
// ], 'Tests/en.php');
6250

6351

64-
/**
65-
* Custom Language Handler
66-
*
67-
* @param string $key
68-
* @return mixed
69-
*/
70-
function __lang($key){
71-
return Translator::trans(
72-
"message.{$key}",
73-
Translator::getLocale()
74-
);
75-
}
76-
77-
/**
78-
* Custom Configuration Handler
79-
*
80-
* @param mixed $key
81-
* @param mixed $default
82-
* @return mixed
83-
*/
84-
function configuration($key, $default = null){
85-
86-
// since the config only takes the filename follow by dot(.) and keyname
87-
// then we can manually include additional folder-name followed by / to indicate that it's a folder
88-
// then message.key_name
89-
// To make this Laravel kind of language, we can add the default value to be returned as the key
90-
91-
return config("configuration/{$key}", $default, 'tests');
92-
}
93-
94-
95-
// Default locale is `en`
96-
// Translator::setLocale('cn');
97-
// Translator::getLocale();
98-
9952
dd(
100-
// config('log', [], 'storage'),
101-
__('message.name'),
102-
__lang('confirm_password'),
103-
configuration('banners'),
53+
Tame::platformIcon('windows'),
54+
55+
to_object($Json),
56+
57+
// server()->toArray($Json),
10458
);
10559

106-
echo "hi";

Tests/time.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
use Tamedevelopers\Support\Time;
4+
5+
require_once __DIR__ . '/../vendor/autoload.php';
6+
7+
8+
9+
// set the default time and timezone
10+
// helper function
11+
ttime(
12+
timezone: 'Africa/Lagos',
13+
time: 'now',
14+
);
15+
16+
17+
// Time::setDate('last week');
18+
// Time::setTimezone('Asia/Tokyo');
19+
20+
// ttime()->setDate('last week');
21+
// ttime()->setTimezone('Asia/Tokyo');
22+
23+
// Time::setDate('last week');
24+
// ttime('yesterday')->time();
25+
// ttime('last week')->sec();
26+
27+
dd(
28+
29+
Time::setTimezone('Asia/Tokyo')
30+
->format('now')
31+
->ago()
32+
,
33+
34+
ttime()->format('yesterday')->ago(),
35+
36+
ttime()->toJs('now')
37+
);

Tests/translate.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
use Tamedevelopers\Support\Translator;
4+
5+
require_once __DIR__ . '/../vendor/autoload.php';
6+
7+
8+
/**
9+
* Custom Language Handler
10+
*
11+
* @param string $key
12+
* @return mixed
13+
*/
14+
function __lang($key){
15+
return Translator::trans(
16+
"message.{$key}",
17+
Translator::getLocale()
18+
);
19+
}
20+
21+
/**
22+
* Custom Configuration Handler
23+
*
24+
* @param mixed $key
25+
* @param mixed $default
26+
* @return mixed
27+
*/
28+
function configuration($key, $default = null){
29+
30+
// since the config only takes the filename follow by dot(.) and keyname
31+
// then we can manually include additional folder-name followed by / to indicate that it's a folder
32+
// then message.key_name
33+
// To make this Laravel kind of language, we can add the default value to be returned as the key
34+
35+
return config("configuration/{$key}", $default, 'tests');
36+
}
37+
38+
39+
dd(
40+
__('message.name'),
41+
42+
43+
__('message.forgot_password'),
44+
45+
__lang('confirm_password'),
46+
47+
// configuration('banners'),
48+
49+
);
50+

0 commit comments

Comments
 (0)