We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 52943f5 commit 09bbd40Copy full SHA for 09bbd40
src/JWT.php
@@ -41,6 +41,15 @@ class JWT
41
*/
42
public static $leeway = 0;
43
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
+
53
/**
54
* @var array<string, string[]>
55
@@ -84,7 +93,7 @@ public static function decode(
84
93
$keyOrKeyArray
85
94
): stdClass {
86
95
// Validate JWT
87
- $timestamp = \time();
96
+ $timestamp = \is_null(static::$timestamp) ? \time() : static::$timestamp;
88
97
89
98
if (empty($keyOrKeyArray)) {
90
99
throw new InvalidArgumentException('Key may not be empty');
0 commit comments