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   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 109
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getToken() 0 4 1
A setToken() 0 4 1
A setExpiresIn() 0 4 1
A getExpiresIn() 0 4 1
A isExpired() 0 4 1
A getRequestId() 0 8 2
A getTokenType() 0 4 1
A setTokenType() 0 4 1
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