Skip to content

Commit 5bbc90c

Browse files
authored
chore: add back timestamp var for compatibility (#412)
1 parent 52943f5 commit 5bbc90c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/JWT.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ class JWT
4141
*/
4242
public static $leeway = 0;
4343

44+
/**
45+
* Allow the current timestamp to be specified.
46+
* Useful for fixing a value within unit testing.
47+
* Will default to PHP time() value if null.
48+
*
49+
* @var ?int
50+
*/
51+
public static $timestamp = null;
52+
4453
/**
4554
* @var array<string, string[]>
4655
*/
@@ -84,7 +93,7 @@ public static function decode(
8493
$keyOrKeyArray
8594
): stdClass {
8695
// Validate JWT
87-
$timestamp = \time();
96+
$timestamp = \is_null(static::$timestamp) ? \time() : static::$timestamp;
8897

8998
if (empty($keyOrKeyArray)) {
9099
throw new InvalidArgumentException('Key may not be empty');

0 commit comments

Comments
 (0)