RefreshTokenRepository::isRefreshTokenRevoked()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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