AuthCodeRepository   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
rs 10
c 0
b 0
f 0
ccs 0
cts 12
cp 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getNewAuthCode() 0 4 1
A persistNewAuthCode() 0 8 2
A revokeAuthCode() 0 4 1
A isAuthCodeRevoked() 0 4 1
1
<?php
2
3
namespace CodexShaper\OAuth2\Server\Repositories;
4
5
use CodexShaper\OAuth2\Server\Entities\AuthCode as AuthCodeEntity;
6
use CodexShaper\OAuth2\Server\Model;
7
use Exception;
8
use League\OAuth2\Server\Entities\AuthCodeEntityInterface;
9
use League\OAuth2\Server\Exception\UniqueTokenIdentifierConstraintViolationException;
10
use League\OAuth2\Server\Repositories\AuthCodeRepositoryInterface;
11
12
class AuthCodeRepository implements AuthCodeRepositoryInterface
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function getNewAuthCode()
18
    {
19
        return new AuthCodeEntity();
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function persistNewAuthCode(AuthCodeEntityInterface $authCodeEntity)
26
    {
27
        try {
28
            Model::storeAuthCode($authCodeEntity);
29
        } catch (UniqueTokenIdentifierConstraintViolationException $ex) {
30
            throw new Exception($ex->getMessage());
31
        }
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function revokeAuthCode($codeId)
38
    {
39
        Model::revoke('authCodeModel', $codeId);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function isAuthCodeRevoked($codeId)
46
    {
47
        return Model::isRevoked('authCodeModel', $codeId);
48
    }
49
}
50