Completed
Push — master ( 4be4b5...14df4a )
by Guillaume
07:45 queued 07:45
created

JwtToken   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getToken() 0 4 1
A isValid() 0 8 2
1
<?php
2
3
namespace Eljam\GuzzleJwt;
4
5
/**
6
 * @author Guillaume Cavana <[email protected]>
7
 */
8
class JwtToken
9
{
10
    /**
11
     * $token.
12
     *
13
     * @var string
14
     */
15
    private $token;
16
17
    /**
18
     * @var \DateTime
19
     */
20
    private $expiration;
21
22
    /**
23
     * Constructor.
24
     *
25
     * @param string    $token
26
     * @param \DateTime $expiration
27
     */
28
    public function __construct($token, \DateTime $expiration = null)
29
    {
30
        $this->token = $token;
31
        $this->expiration = $expiration;
32
    }
33
34
    /**
35
     * getToken.
36
     *
37
     * @return string
38
     */
39
    public function getToken()
40
    {
41
        return $this->token;
42
    }
43
44
    /**
45
     * @return bool
46
     */
47
    public function isValid()
48
    {
49
        if (!$this->expiration) {
50
            return false;
51
        }
52
53
        return (new \DateTime()) < $this->expiration;
54
    }
55
}
56