Skip to content

Commit 5876254

Browse files
disposable email utility added
1 parent 2ecbb4b commit 5876254

File tree

7 files changed

+44
-23
lines changed

7 files changed

+44
-23
lines changed

src/Cookie.php

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Tamedevelopers\Support\Str;
88
use Tamedevelopers\Support\Time;
99

10-
class Cookie{
10+
final class Cookie{
1111

1212
/**
1313
* Site name
@@ -57,10 +57,10 @@ protected static function init()
5757

5858
/**
5959
* Create Cookie
60-
* @param string $name
60+
* @param mixed $name
6161
* - Cookie Name
6262
*
63-
* @param string|null $value
63+
* @param mixed $value
6464
* - Cookie Value
6565
*
6666
* @param int|string $minutes
@@ -99,6 +99,9 @@ public static function set($name, $value = null, $minutes = 0, $path = null, $do
9999
$path, $value, $domain, $secure, $httponly, $force
100100
);
101101

102+
$name = self::getItemValue($name);
103+
$value = self::getItemValue($value);
104+
102105
// Prefer new setcookie signature with array options (PHP 7.3+), fallback otherwise
103106
if (!headers_sent() || $force === true) {
104107
$options = [
@@ -113,28 +116,28 @@ public static function set($name, $value = null, $minutes = 0, $path = null, $do
113116
// Try modern signature; if it fails (older PHP), fallback to legacy
114117
try {
115118
if (PHP_VERSION_ID >= 70300) {
116-
@setcookie($name, (string) $value, $options);
119+
@setcookie($name, $value, $options);
117120
} else {
118-
@setcookie($name, (string) $value, (int) $expires, (string) $path, (string) $domain, (bool) $secure, (bool) $httponly);
121+
@setcookie($name, $value, (int) $expires, (string) $path, (string) $domain, (bool) $secure, (bool) $httponly);
119122
}
120123
} catch (\Throwable $e) {
121-
@setcookie($name, (string) $value, (int) $expires, (string) $path, (string) $domain, (bool) $secure, (bool) $httponly);
124+
@setcookie($name, $value, (int) $expires, (string) $path, (string) $domain, (bool) $secure, (bool) $httponly);
122125
}
123126
}
124127
}
125128

126129
/**
127130
* Expire the given cookie.
128131
*
129-
* @param string $name
132+
* @param mixed $name
130133
* @param string|null $path
131134
* @param string|null $domain
132135
* @return void
133136
*/
134137
public static function forget($name, $path = null, $domain = null)
135138
{
136139
self::set(
137-
name: $name,
140+
name: self::getItemValue($name),
138141
minutes: 'last year',
139142
path: $path,
140143
domain: $domain,
@@ -145,7 +148,7 @@ public static function forget($name, $path = null, $domain = null)
145148
/**
146149
* Expire the given cookie.
147150
*
148-
* @param string $name
151+
* @param mixed $name
149152
* @param string|null $path
150153
* @param string $domain
151154
* @return void
@@ -198,26 +201,28 @@ public static function getExpire()
198201
/**
199202
* Cookie has name that exists
200203
*
201-
* @param string $name
204+
* @param mixed $name
202205
* - Cookie name
203206
*
204207
* @return bool
205208
*/
206209
public static function has($name = null)
207210
{
208-
return isset($_COOKIE[(string) $name]);
211+
return isset($_COOKIE[self::getItemValue($name)]);
209212
}
210213

211214
/**
212215
* Get cookie
213-
* @param string $name
216+
* @param mixed $name
214217
* - Cookie name
215218
*
216219
* @return mixed
217220
*/
218221
public static function get($name = null)
219222
{
220-
return self::has($name) ? $_COOKIE[(string) $name] : null;
223+
$name = self::getItemValue($name);
224+
225+
return self::has($name) ? $_COOKIE[$name] : null;
221226
}
222227

223228
/**
@@ -232,6 +237,21 @@ public static function all($name = null)
232237
{
233238
return self::get($name) ?? $_COOKIE;
234239
}
240+
241+
/**
242+
* Item Value
243+
*
244+
* @param mixed $value
245+
* @return string
246+
*/
247+
private static function getItemValue($value = null)
248+
{
249+
if(is_array($value)){
250+
$value = Str::head($value);
251+
}
252+
253+
return (string) $value;
254+
}
235255

236256
/**
237257
* Set minutes

src/Process/Session/Handlers/RedisSessionHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public function __construct(
4444
int $ttl = 1440
4545
) {
4646
// Avoid hard typehint to keep IDE analyzers happy when extension is missing
47-
$this->redis = new \Redis();
47+
$className = '\Redis';
48+
$this->redis = new $className();
4849
$this->redis->connect($host, $port, $timeout);
4950
if ($auth !== null && $auth !== '') {
5051
$this->redis->auth($auth);

src/Str.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public static function forgetArrayKeys($array, ...$keys)
240240
*
241241
* @param array $array The input data array.
242242
* @param string $key The key to use for conversion.
243-
* @param int $case The case sensitivity option for key comparison (upper, lower).
243+
* @param string $case The case sensitivity option for key comparison (upper, lower).
244244
*
245245
* @return array
246246
* - The converted array with specified key as keys if available, else the original array

src/Tame.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ public static function isArraySame(?array $data = [])
663663
*
664664
* @return array
665665
*/
666-
public static function sortArray(?array &$data = [], ?string $type = 'sort')
666+
public static function sortArray(&$data = [], $type = 'sort')
667667
{
668668
// Validate that $data is an array
669669
if (!is_array($data)) {

src/Time.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
* All methods are documented at their definitions for clarity.
2525
*/
26-
class Time {
26+
final class Time {
2727

2828
use TimeTrait, TimeExtraTrait;
2929

src/Traits/StrTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static function changeKeysFromArray($array, $fromKey, $toKey = null): arr
4141
*
4242
* @param array $array The input data array.
4343
* @param string $key The key to use for conversion.
44-
* @param int $case The case sensitivity option for key comparison (upper, lower).
44+
* @param string $case The case sensitivity option for key comparison (upper, lower).
4545
*
4646
* @return array
4747
* - The converted array with specified key as keys if available, else the original array
@@ -206,7 +206,7 @@ private static function replaceSubject($subject = null): mixed
206206
* Convert the case of a string based on the specified type.
207207
*
208208
* @param mixed $string The input string
209-
* @param string|int|null $type The case to convert: 'lower', 'upper', or 'unchanged'
209+
* @param string|null $type The case to convert: 'lower', 'upper', or 'unchanged'
210210
*
211211
* @return string The string with converted case
212212
*/

src/Traits/TimeTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected static function isTimeInstance()
3434

3535
/**
3636
* Added a base resolver to reuse the latest instance context
37-
* @return $this
37+
* @return \Time
3838
*/
3939
private static function baseInstance()
4040
{
@@ -52,7 +52,7 @@ private static function baseInstance()
5252
* - Only if no static data available, bind it to the passed clone object
5353
*
5454
* @param \Time $clone
55-
* @return $this
55+
* @return \Time
5656
*/
5757
private static function keepStaticBinding($clone)
5858
{
@@ -66,7 +66,7 @@ private static function keepStaticBinding($clone)
6666
/**
6767
* Clone a new instance of the owning class.
6868
*
69-
* @return $this A shallow clone of the current instance.
69+
* @return \Time A shallow clone of the current instance.
7070
*/
7171
private function clone()
7272
{
@@ -315,7 +315,7 @@ private static function nonExistMethod($method = null, $args = null, $clone = nu
315315
'gettimezone' => '__getTimezone',
316316
'settimezone' => '__setTimezone',
317317
'diffbetween', 'timediffbetween' => '__timeDifferenceBetween',
318-
'diff', 'timediff' => '__timeDifference',
318+
'diff', 'timediff', 'timedifference' => '__timeDifference',
319319
'daterange', 'range' => 'dateRange',
320320
'ago', 'timeago' => '__timeAgo',
321321
'addsecond' => 'addSeconds',

0 commit comments

Comments
 (0)