AuthCodeRepository::persistNewAuthCode()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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