Completed
Push — master ( 022625...2b82d4 )
by Florent
05:58
created

IssuedAtChecker::checkClaim()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 11
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace Jose\Checker;
13
14
use Assert\Assertion;
15
use Jose\Object\JWTInterface;
16
17
class IssuedAtChecker implements ClaimCheckerInterface
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function checkClaim(JWTInterface $jwt)
23
    {
24
        if (!$jwt->hasClaim('iat')) {
25
            return [];
26
        }
27
28
        $iat = (int) $jwt->getClaim('iat');
29
        Assertion::lessOrEqualThan($iat, time(), 'The JWT is issued in the futur.');
30
31
        return ['iat'];
32
    }
33
}
34