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

DefaultScopePolicy::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
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
}