Skip to content

Commit c40229f

Browse files
author
drtriumph
committed
Some minor cleanup from @brendo's PR with a quick rename
1 parent ea4db8d commit c40229f

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

Authentication/JWT.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static function decode($jwt, $key = null, $verify = true)
7474

7575
// Check if the nbf if it is defined.
7676
if (isset($payload->nbf) && $payload->nbf > time()) {
77-
throw new TooEarlyException(
77+
throw new BeforeValidException(
7878
'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->nbf)
7979
);
8080
}

Exceptions/BeforeValidException.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
class BeforeValidException extends UnexpectedValueException
4+
{
5+
6+
}

Exceptions/ExpiredException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
class ExpiredException extends UnexpectedValueException
44
{
55

6-
}
6+
}

Exceptions/SignatureInvalidException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
class SignatureInvalidException extends UnexpectedValueException
44
{
55

6-
}
6+
}

Exceptions/TooEarlyException.php

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/JWTTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public function testExpiredToken()
4545
JWT::decode($encoded, 'my_key');
4646
}
4747

48-
public function testTooEarlyToken()
48+
public function testBeforeValidToken()
4949
{
50-
$this->setExpectedException('TooEarlyException');
50+
$this->setExpectedException('BeforeValidException');
5151
$payload = array(
5252
"message" => "abc",
53-
"nbf" => time() + 20); // time in the past
53+
"nbf" => time() + 20); // time in the future
5454
$encoded = JWT::encode($payload, 'my_key');
5555
JWT::decode($encoded, 'my_key');
5656
}

0 commit comments

Comments
 (0)