Failed Conditions
Push — ng ( 57a3a2...d2fe45 )
by Florent
03:39
created

ResourceServerRepository::find()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
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\Core\ResourceServer\ResourceServer as ResourceServerInterface;
17
use OAuth2Framework\Component\Core\ResourceServer\ResourceServerId;
18
use OAuth2Framework\Component\Core\ResourceServer\ResourceServerRepository as ResourceServerRepositoryInterface;
19
use OAuth2Framework\Component\IssuerDiscoveryEndpoint\ResourceId;
20
21
final class ResourceServerRepository implements ResourceServerRepositoryInterface
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function find(ResourceServerId $resourceServerId): ? ResourceServerInterface
27
    {
28
        if ($resourceServerId->getValue() === 'http://foo.com') {
29
            return new ResourceServer($resourceServerId);
30
        }
31
32
        return null;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function supports(ResourceId $resourceId): bool
39
    {
40
        return mb_substr($resourceId->getValue(), 0, 14) === 'http://foo.com';
41
    }
42
}
43