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

ResourceRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A find() 0 4 2
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