Failed Conditions
Push — master ( ed3bfb...d044dc )
by Florent
06:10
created

ScopeRepository   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 3 1
A __construct() 0 4 1
A get() 0 7 2
A all() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2019 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\ServerBundle\Tests\TestBundle\Repository;
15
16
use OAuth2Framework\Component\Scope\Scope as ScopeInterface;
17
use OAuth2Framework\Component\Scope\ScopeRepository as ScopeRepositoryInterface;
18
use OAuth2Framework\ServerBundle\Tests\TestBundle\Entity\Scope;
19
20
final class ScopeRepository implements ScopeRepositoryInterface
21
{
22
    /**
23
     * @var ScopeInterface[]
24
     */
25
    private $scopes = [];
26
27
    public function __construct()
28
    {
29
        $this->scopes['openid'] = new Scope('openid');
30
        $this->scopes['scope1'] = new Scope('scope1');
31
    }
32
33
    public function has(string $scope): bool
34
    {
35
        return \array_key_exists($scope, $this->scopes);
36
    }
37
38
    public function get(string $scope): ScopeInterface
39
    {
40
        if (!$this->has($scope)) {
41
            throw new \InvalidArgumentException(\Safe\sprintf('The scope "%s" is not supported.', $scope));
42
        }
43
44
        return $this->scopes[$scope];
45
    }
46
47
    public function all(): array
48
    {
49
        return array_values($this->scopes);
50
    }
51
}
52