Failed Conditions
Push — ng ( 14a26e...d8e250 )
by Florent
03:43
created

InitialAccessTokenRepository::getFromCache()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
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 OAuth2Framework\Component\ClientRegistrationEndpoint\InitialAccessToken;
17
use OAuth2Framework\Component\ClientRegistrationEndpoint\InitialAccessTokenId;
18
19
class InitialAccessTokenRepository implements \OAuth2Framework\Component\ClientRegistrationEndpoint\InitialAccessTokenRepository
20
{
21
    /**
22
     * @var InitialAccessToken[]
23
     */
24
    private $initialAccessTokens = [];
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function find(InitialAccessTokenId $initialAccessTokenId): ? InitialAccessToken
30
    {
31
        return array_key_exists($initialAccessTokenId->getValue(), $this->initialAccessTokens) ? $this->initialAccessTokens[$initialAccessTokenId->getValue()] : null;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function save(InitialAccessToken $initialAccessToken)
38
    {
39
        $this->initialAccessTokens[$initialAccessToken->getTokenId()->getValue()] = $initialAccessToken;
40
    }
41
}
42