OAuthToken::hasExpired()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace NodeRED;
4
5
class OAuthToken implements \Serializable
6
{
7
    private $accessToken;
8
    private $expiryTime;
9
    private $tokenType;
10
11 4
    public function __construct($accessToken, $expirySeconds, $tokenType)
12
    {
13 4
        $this->accessToken = $accessToken;
14 4
        $this->expiryTime = time() + $expirySeconds;
15 4
        $this->tokenType = $tokenType;
16 4
    }
17
18 1
    public function getAccessToken()
19
    {
20 1
        return $this->accessToken;
21
    }
22
23 1
    public function hasExpired()
24
    {
25 1
        return time() > $this->expiryTime;
26
    }
27
28 1
    public function getTokenType()
29
    {
30 1
        return $this->tokenType;
31
    }
32
33 1
    public function getAuthorizationString()
34
    {
35 1
        return $this->getTokenType() . ' ' . $this->getAccessToken();
36
    }
37
38 1
    public function serialize()
39
    {
40 1
        $collected = [$this->accessToken, $this->expiryTime, $this->tokenType];
41
42 1
        return serialize($collected);
43
    }
44
45 1
    public function unserialize($data)
46
    {
47 1
        $collected = unserialize($data);
48
49 1
        $this->accessToken = $collected[0];
50 1
        $this->expiryTime = $collected[1];
51 1
        $this->tokenType = $collected[2];
52 1
    }
53
}
54