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

IssuedAtChecker   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 2
c 2
b 1
f 1
lcom 0
cbo 2
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A checkClaim() 0 11 2
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