RefreshToken   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 5
c 3
b 1
f 0
lcom 1
cbo 1
dl 0
loc 40
ccs 11
cts 11
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaults() 0 4 1
A setRefreshToken() 0 4 1
A hasRefreshToken() 0 4 1
A getToken() 0 8 2
1
<?php
2
3
namespace CommerceGuys\Guzzle\Oauth2\GrantType;
4
5
/**
6
 * Refresh token grant type.
7
 *
8
 * @link http://tools.ietf.org/html/rfc6749#section-6
9
 */
10
class RefreshToken extends GrantTypeBase implements RefreshTokenGrantTypeInterface
11
{
12
    protected $grantType = 'refresh_token';
13
14
    /**
15
     * @inheritdoc
16
     */
17 3
    protected function getDefaults()
18
    {
19 3
        return parent::getDefaults() + ['refresh_token' => ''];
20
    }
21
22
    /**
23
     * @inheritdoc
24
     */
25 2
    public function setRefreshToken($refreshToken)
26
    {
27 2
        $this->config['refresh_token'] = $refreshToken;
28 2
    }
29
30
    /**
31
     * @inheritdoc
32
     */
33 3
    public function hasRefreshToken()
34
    {
35 3
        return !empty($this->config['refresh_token']);
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41 3
    public function getToken()
42
    {
43 3
        if (!$this->hasRefreshToken()) {
44 1
            throw new \RuntimeException("Refresh token not available");
45
        }
46
47 2
        return parent::getToken();
48
    }
49
}
50