Completed
Push — master ( 704578...e88511 )
by Alex
32:19
created

ScopeRepository::getScopeEntityByIdentifier()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 20
rs 9.4285
cc 2
eloc 11
nc 2
nop 1
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 OAuth2ServerExamples\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 implements ScopeRepositoryInterface
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function getScopeEntityByIdentifier($scopeIdentifier)
22
    {
23
        $scopes = [
24
            'basic' => [
25
                'description' => 'Basic details about you',
26
            ],
27
            'email' => [
28
                'description' => 'Your email address',
29
            ],
30
        ];
31
32
        if (array_key_exists($scopeIdentifier, $scopes) === false) {
33
            return;
34
        }
35
36
        $scope = new ScopeEntity();
37
        $scope->setIdentifier($scopeIdentifier);
38
39
        return $scope;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function finalizeScopes(
46
        array $scopes,
47
        $grantType,
48
        ClientEntityInterface $clientEntity,
49
        $userIdentifier = null
50
    ) {
51
        return $scopes;
52
    }
53
}
54