RefreshTokenRepository   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 38
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getNewRefreshToken() 0 4 1
A persistNewRefreshToken() 0 8 2
A revokeRefreshToken() 0 4 1
A isRefreshTokenRevoked() 0 4 1
1
<?php
2
3
namespace CodexShaper\OAuth2\Server\Repositories;
4
5
use CodexShaper\OAuth2\Server\Entities\RefreshToken as RefreshTokenEntity;
6
use CodexShaper\OAuth2\Server\Model;
7
use Exception;
8
use League\OAuth2\Server\Entities\RefreshTokenEntityInterface;
9
use League\OAuth2\Server\Exception\UniqueTokenIdentifierConstraintViolationException;
10
use League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface;
11
12
class RefreshTokenRepository implements RefreshTokenRepositoryInterface
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function getNewRefreshToken()
18
    {
19
        return new RefreshTokenEntity();
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function persistNewRefreshToken(RefreshTokenEntityInterface $refreshTokenEntity)
26
    {
27
        try {
28
            Model::storeRefreshToken($refreshTokenEntity);
29
        } catch (UniqueTokenIdentifierConstraintViolationException $ex) {
30
            throw new Exception($ex->getMessage());
31
        }
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function revokeRefreshToken($tokenId)
38
    {
39
        Model::revoke('refreshTokenModel', $tokenId);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function isRefreshTokenRevoked($tokenId)
46
    {
47
        return Model::isRevoked('refreshTokenModel', $tokenId);
48
    }
49
}
50