Passed
Pull Request — master (#1138)
by
unknown
02:07
created

AccessTokenRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author      Alex Bilbie <[email protected]>
4
 * @copyright   Copyright (c) Alex Bilbie
5
 * @license     http://mit-license.org/
6
 *
7
 * @link        https://github.com/thephpleague/oauth2-server
8
 */
9
10
namespace OAuth2ServerExamples\Repositories;
11
12
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
13
use League\OAuth2\Server\Entities\ClientEntityInterface;
14
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
15
use OAuth2ServerExamples\Entities\AccessTokenEntity;
16
17
class AccessTokenRepository implements AccessTokenRepositoryInterface
18
{
19
20
    /**
21
     * @var string
22
     */
23
    private $issuer;
24
25
    /**
26
     * @param string $domain token issuer identifier
27
     */
28
    public function __construct($issuer)
29
    {
30
        $this->$issuer = $issuer;
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEntity)
37
    {
38
        // Some logic here to save the access token to a database
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function revokeAccessToken($tokenId)
45
    {
46
        // Some logic here to revoke the access token
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function isAccessTokenRevoked($tokenId)
53
    {
54
        return false; // Access token hasn't been revoked
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function getNewToken(ClientEntityInterface $clientEntity, array $scopes, $userIdentifier = null)
61
    {
62
        $accessToken = new AccessTokenEntity();
63
        $accessToken->setClient($clientEntity);
64
        foreach ($scopes as $scope) {
65
            $accessToken->addScope($scope);
66
        }
67
        $accessToken->setUserIdentifier($userIdentifier);
68
        $accessToken->setIssuer($this->domain);
0 ignored issues
show
Bug Best Practice introduced by
The property domain does not exist on OAuth2ServerExamples\Rep...s\AccessTokenRepository. Did you maybe forget to declare it?
Loading history...
69
70
        return $accessToken;
71
    }
72
}
73