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

Server::__construct()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 24
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 4
nop 9
dl 0
loc 24
rs 8.9713
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Alexandre
5
 * Date: 23/01/2018
6
 * Time: 00:10
7
 */
8
9
namespace OAuth2OLD\OpenID;
10
11
12
use OAuth2OLD\ClientAuthentication\Guard;
13
use OAuth2OLD\OpenID\Endpoints\AuthorizationEndpoint;
14
use OAuth2OLD\Repositories\ResponseModeRepository;
15
use OAuth2OLD\OpenID\Repositories\ResponseTypeRepository;
16
use OAuth2OLD\Providers\ResourceOwnerProviderInterface;
17
use OAuth2OLD\Repositories\ClientAuthenticatorRepository;
18
use OAuth2OLD\OpenID\Repositories\ConfigurationRepository;
19
use OAuth2OLD\Repositories\GrantTypeRepository;
20
//use OAuth2\Repositories\ResponseTypeRepository;
21
use OAuth2OLD\OpenID\Repositories\StorageRepository;
22
use OAuth2OLD\ScopePolicy\ScopePolicyManager;
23
24
class Server extends \OAuth2OLD\Server
25
{
26
    /**
27
     * @var AuthorizationEndpoint
28
     */
29
    protected $authorizationEndpoint;
30
    /**
31
     * @var ResponseTypeRepository
32
     */
33
    protected $responseTypeRepository;
34
35
    /**
36
     * Server constructor.
37
     * @param ResourceOwnerProviderInterface $resourceOwnerProvider
38
     * @param null|StorageRepository $storageRepository
39
     * @param null|ConfigurationRepository $configurationRepository
40
     * @param null|ResponseTypeRepository $responseTypeRepository
41
     * @param null|GrantTypeRepository $grantTypeRepository
42
     * @param null|ClientAuthenticatorRepository $clientAuthenticatorRepository
43
     * @param null|Guard $guard
44
     * @param null|ScopePolicyManager $scopePolicyManager
45
     * @param null|ResponseModeRepository $responseModeRepository
46
     * @throws \Exception
47
     */
48
    public function __construct(ResourceOwnerProviderInterface $resourceOwnerProvider,
49
                                StorageRepository $storageRepository,
50
                                ?ConfigurationRepository $configurationRepository = null,
51
                                ?ResponseTypeRepository $responseTypeRepository = null,
52
                                ?GrantTypeRepository $grantTypeRepository = null,
53
                                ?ClientAuthenticatorRepository $clientAuthenticatorRepository = null,
54
                                ?Guard $guard = null,
55
                                ?ScopePolicyManager $scopePolicyManager = null,
56
                                ?ResponseModeRepository $responseModeRepository = null)
57
    {
58
        if (is_null($configurationRepository)) {
59
            $configurationRepository = new ConfigurationRepository();
60
        }
61
62
        if (is_null($responseTypeRepository)) {
63
            $responseTypeRepository = new ResponseTypeRepository(
64
                ResponseTypeRepository::getDefaultResponseTypes($configurationRepository, $storageRepository));
65
        }
66
67
        parent::__construct($resourceOwnerProvider, $storageRepository, $configurationRepository,
68
            $responseTypeRepository, $grantTypeRepository, $clientAuthenticatorRepository, $guard,
69
            $scopePolicyManager, $responseModeRepository);
70
71
        $this->authorizationEndpoint = new AuthorizationEndpoint($this);
72
    }
73
74
}