Failed Conditions
Push — ng ( 870bee...532144 )
by Florent
04:07
created

AccessTokenRepository::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 5
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\Bundle\Tests\TestBundle\Entity;
15
16
use Base64Url\Base64Url;
17
use OAuth2Framework\Component\Core\AccessToken\AccessToken;
18
use OAuth2Framework\Component\Core\AccessToken\AccessTokenId;
19
use OAuth2Framework\Component\Core\AccessToken\AccessTokenRepository as AccessTokenRepositoryInterface;
20
use OAuth2Framework\Component\Core\Client\ClientId;
21
use OAuth2Framework\Component\Core\DataBag\DataBag;
22
use OAuth2Framework\Component\Core\ResourceOwner\ResourceOwnerId;
23
use OAuth2Framework\Component\Core\ResourceServer\ResourceServerId;
24
25
class AccessTokenRepository implements AccessTokenRepositoryInterface
26
{
27
    /**
28
     * @var AccessToken[]
29
     */
30
    private $accessTokens = [];
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function find(AccessTokenId $accessTokenId)
36
    {
37
        return array_key_exists($accessTokenId->getValue(), $this->accessTokens) ? $this->accessTokens[$accessTokenId->getValue()] : null;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function save(AccessToken $accessToken)
44
    {
45
        $this->accessTokens[$accessToken->getTokenId()->getValue()] = $accessToken;
46
    }
47
}
48