Failed Conditions
Push — master ( f0c028...ba72c1 )
by Florent
05:06
created

IssuedAtChecker   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A checkClaim() 0 9 3
A supportedClaim() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2017 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace Jose\Component\Checker;
15
16
/**
17
 * Class IssuedAtChecker.
18
 */
19
final class IssuedAtChecker implements ClaimCheckerInterface
20
{
21
    private const CLAIM_NAME = 'iat';
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function checkClaim($value)
27
    {
28
        if (!is_int($value)) {
29
            throw new \InvalidArgumentException('The claim "iat" must be an integer.');
30
        }
31
        if (time() < $value) {
32
            throw new \InvalidArgumentException('The JWT is issued in the future.');
33
        }
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function supportedClaim(): string
40
    {
41
        return self::CLAIM_NAME;
42
    }
43
}
44