Failed Conditions
Push — ng ( 17df75...6face8 )
by Florent
04:09
created

ResourceRepository::find()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
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\IssuerDiscoveryEndpoint\ResourceObject as ResourceObjectInterface;
17
use OAuth2Framework\Component\IssuerDiscoveryEndpoint\ResourceId;
18
use OAuth2Framework\Component\IssuerDiscoveryEndpoint\ResourceRepository as ResourceRepositoryInterface;
19
20
class ResourceRepository implements ResourceRepositoryInterface
21
{
22
    /**
23
     * @var ResourceObjectInterface[]
24
     */
25
    private $resources = [];
26
27
    public function __construct()
28
    {
29
        $this->resources['john'] = new ResourceObject('https://server.example.com');
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function find(ResourceId $resourceId): ?ResourceObjectInterface
36
    {
37
        return array_key_exists($resourceId->getValue(), $this->resources) ? $this->resources[$resourceId->getValue()] : null;
38
    }
39
}
40