Passed
Pull Request — master (#13)
by Steve
03:07
created

ScopeRepository::getScopeEntityByIdentifier()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 23
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 12
nc 2
nop 1
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author      Alex Bilbie <[email protected]>
4
 * @copyright   Copyright (c) Alex Bilbie
5
 * @license     http://mit-license.org/
6
 *
7
 * @link        https://github.com/thephpleague/oauth2-server
8
 */
9
10
namespace OpenIDConnectServerExamples\Repositories;
11
12
use League\OAuth2\Server\Entities\ClientEntityInterface;
13
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
14
use OAuth2ServerExamples\Entities\ScopeEntity;
15
16
class ScopeRepository extends \OAuth2ServerExamples\Repositories\ScopeRepository
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function getScopeEntityByIdentifier($scopeIdentifier)
22
    {
23
        $scopes = [
24
            // Without this OpenID Connect cannot work.
25
            'openid' => [
26
                'description' => 'Enable OpenID Connect support'
27
            ],
28
            'basic' => [
29
                'description' => 'Basic details about you',
30
            ],
31
            'email' => [
32
                'description' => 'Your email address',
33
            ],
34
        ];
35
36
        if (array_key_exists($scopeIdentifier, $scopes) === false) {
37
            return;
38
        }
39
40
        $scope = new ScopeEntity();
41
        $scope->setIdentifier($scopeIdentifier);
42
43
        return $scope;
44
    }
45
}
46