Completed
Push — master ( 6e52f0...d9a404 )
by Alexandre
02:29
created

DefaultScopePolicy   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultScopes() 0 3 2
A __construct() 0 5 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: GCC-MED
5
 * Date: 15/01/2018
6
 * Time: 11:50
7
 */
8
9
namespace OAuth2OLD\ScopePolicy\Policies;
10
11
12
use OAuth2OLD\Config;
13
use OAuth2OLD\Repositories\ConfigurationRepository;
14
use OAuth2OLD\Roles\ClientInterface;
15
16
class DefaultScopePolicy implements ScopePolicyInterface
17
{
18
    /**
19
     * @var ConfigurationRepository
20
     */
21
    protected $configurationRepository;
22
    protected $defaultScopes;
23
24
    public function __construct(ConfigurationRepository $configurationRepository)
25
    {
26
        $this->configurationRepository = $configurationRepository;
27
        $defaultScopes = $this->configurationRepository->getConfig(Config::DEFAULT_SCOPES);
28
        $this->defaultScopes = is_string($defaultScopes) ? explode(' ', $defaultScopes) : $defaultScopes;
29
    }
30
31
32
    function getDefaultScopes(ClientInterface $client): ?array
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
33
    {
34
        return $client->getDefaultScopes() ? $client->getDefaultScopes() : $this->defaultScopes;
35
    }
36
}