Conditions | 4 |
Paths | 4 |
Total Lines | 24 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | public function verify(Token $token) |
||
12 | { |
||
13 | /** @var Claim\NotBefore $notBeforeClaim */ |
||
14 | $notBeforeClaim = $token->getPayload()->findClaimByName(Claim\NotBefore::NAME); |
||
15 | |||
16 | if (null === $notBeforeClaim) { |
||
17 | return null; |
||
18 | } |
||
19 | |||
20 | $now = new \DateTime('now', new \DateTimeZone('UTC')); |
||
21 | |||
22 | if (!is_long($notBeforeClaim->getValue())) { |
||
23 | throw new \InvalidArgumentException(sprintf( |
||
24 | 'Invalid not before timestamp "%s"', |
||
25 | $notBeforeClaim->getValue() |
||
26 | )); |
||
27 | } |
||
28 | |||
29 | if ($now->getTimestamp() < $notBeforeClaim->getValue()) { |
||
30 | $notBefore = new \DateTime(); |
||
31 | $notBefore->setTimestamp($notBeforeClaim->getValue()); |
||
32 | throw new TooEarlyException($notBefore); |
||
33 | } |
||
34 | } |
||
35 | } |
||
36 |