RefreshTokenRepository   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 32
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A persistNewRefreshToken() 0 2 1
A revokeRefreshToken() 0 2 1
A getNewRefreshToken() 0 3 1
A isRefreshTokenRevoked() 0 3 1
1
<?php
2
3
/**
4
 * @author      Alex Bilbie <[email protected]>
5
 * @copyright   Copyright (c) Alex Bilbie
6
 * @license     http://mit-license.org/
7
 *
8
 * @link        https://github.com/thephpleague/oauth2-server
9
 */
10
11
declare(strict_types=1);
12
13
namespace OAuth2ServerExamples\Repositories;
14
15
use League\OAuth2\Server\Entities\RefreshTokenEntityInterface;
16
use League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface;
17
use OAuth2ServerExamples\Entities\RefreshTokenEntity;
18
19
class RefreshTokenRepository implements RefreshTokenRepositoryInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function persistNewRefreshToken(RefreshTokenEntityInterface $refreshTokenEntity): void
25
    {
26
        // Some logic to persist the refresh token in a database
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function revokeRefreshToken($tokenId): void
33
    {
34
        // Some logic to revoke the refresh token in a database
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function isRefreshTokenRevoked($tokenId): bool
41
    {
42
        return false; // The refresh token has not been revoked
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function getNewRefreshToken(): ?RefreshTokenEntityInterface
49
    {
50
        return new RefreshTokenEntity();
51
    }
52
}
53