Failed Conditions
Push — ng ( efd567...e5f725 )
by Florent
04:15
created

ScopeRepository   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 44
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A has() 0 4 1
A get() 0 8 2
A all() 0 4 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\Scope\Scope as ScopeInterface;
17
use OAuth2Framework\Component\Scope\ScopeRepository as ScopeRepositoryInterface;
18
19
final class ScopeRepository implements ScopeRepositoryInterface
20
{
21
    /**
22
     * @var ScopeInterface[]
23
     */
24
    private $scopes = [];
25
26
    /**
27
     * ScopeRepository constructor.
28
     */
29
    public function __construct()
30
    {
31
        $this->scopes['openid'] = new Scope('openid');
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function has(string $scope): bool
38
    {
39
        return array_key_exists($scope, $this->scopes);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function get(string $scope): ScopeInterface
46
    {
47
        if (!$this->has($scope)) {
48
            throw new \InvalidArgumentException(sprintf('The scope "%s" is not supported.', $scope));
49
        }
50
51
        return $this->scopes[$scope];
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function all(): array
58
    {
59
        return array_values($this->scopes);
60
    }
61
62
}
63