GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AccessToken::isExpired()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Onend\PayPal\Common\Auth;
4
5
class AccessToken implements AccessTokenInterface
6
{
7
    /**
8
     * @var string
9
     */
10
    private $token;
11
12
    /**
13
     * @var string
14
     */
15
    private $tokenType;
16
17
    /**
18
     * @var int
19
     */
20
    private $expiresIn;
21
22
    /**
23
     * Token created at, it's need to check expiration
24
     *
25
     * @var int
26
     */
27
    private $createdTime;
28
29
    /**
30
     * API call delays and any delay between the time the token is retrieved and subsequently used
31
     *
32
     * @var int
33
     */
34
    private static $expiryBuffer = 120;
35
36
    /**
37
     * @var string
38
     */
39
    private $requestId;
40
41
    public function __construct()
42
    {
43
        $this->createdTime = time();
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function getToken()
50
    {
51
        return $this->token;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function setToken($token)
58
    {
59
        $this->token = $token;
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function setExpiresIn($expiresIn)
66
    {
67
        $this->expiresIn = (int)$expiresIn;
68
    }
69
70
    /**
71
     * {@inheritdoc}
72
     */
73
    public function getExpiresIn()
74
    {
75
        return (int)$this->expiresIn;
76
    }
77
78
    /**
79
     * {@inheritdoc}
80
     */
81
    public function isExpired()
82
    {
83
        return (time() - $this->createdTime) > ($this->getExpiresIn() - self::$expiryBuffer);
84
    }
85
86
    /**
87
     * {@inheritdoc}
88
     */
89
    public function getRequestId()
90
    {
91
        if ($this->requestId === null) {
92
            $this->requestId = sha1(getmypid() . $this->createdTime . mt_rand(0, 0xffff));
93
        }
94
95
        return $this->requestId;
96
    }
97
98
    /**
99
     * {@inheritdoc}
100
     */
101
    public function getTokenType()
102
    {
103
        return $this->tokenType;
104
    }
105
106
    /**
107
     * {@inheritdoc}
108
     */
109
    public function setTokenType($tokenType)
110
    {
111
        $this->tokenType = $tokenType;
112
    }
113
}
114