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
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 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', $tokenId);
0 ignored issues
show
Bug introduced by
The variable $tokenId does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function isAuthCodeRevoked($codeId)
46
    {
47
        return Model::isRevoked('authCodeModel', $tokenId);
0 ignored issues
show
Bug introduced by
The variable $tokenId does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
48
    }
49
}
50