Passed
Push — master ( 5ed34a...340187 )
by Alexandre
02:40
created

Server::getAuthorizationEndpoint()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Alexandre
5
 * Date: 23/01/2018
6
 * Time: 00:10
7
 */
8
9
namespace OAuth2\OpenID;
10
11
12
use OAuth2\ClientAuthentication\Guard;
13
use OAuth2\OpenID\Endpoints\AuthorizationEndpoint;
14
use OAuth2\Providers\ResourceOwnerProviderInterface;
15
use OAuth2\Repositories\ClientAuthenticatorRepository;
16
use OAuth2\Repositories\ConfigurationRepository;
17
use OAuth2\Repositories\GrantTypeRepository;
18
use OAuth2\Repositories\ResponseTypeRepository;
19
use OAuth2\Repositories\StorageRepository;
20
use OAuth2\ScopePolicy\Manager;
21
22
class Server extends \OAuth2\Server
23
{
24
    /**
25
     * Server constructor.
26
     * @param ResourceOwnerProviderInterface $resourceOwnerProvider
27
     * @param null|StorageRepository $storageRepository
28
     * @param null|ConfigurationRepository $configurationRepository
29
     * @param null|ResponseTypeRepository $responseTypeRepository
30
     * @param null|GrantTypeRepository $grantTypeRepository
31
     * @param null|ClientAuthenticatorRepository $clientAuthenticatorRepository
32
     * @param null|Guard $guard
33
     * @param null|Manager $scopePolicyManager
34
     * @throws \Exception
35
     */
36
    public function __construct(ResourceOwnerProviderInterface $resourceOwnerProvider,
37
                                ?StorageRepository $storageRepository,
38
                                ?ConfigurationRepository $configurationRepository = null,
39
                                ?ResponseTypeRepository $responseTypeRepository = null,
40
                                ?GrantTypeRepository $grantTypeRepository = null,
41
                                ?ClientAuthenticatorRepository $clientAuthenticatorRepository = null,
42
                                ?Guard $guard = null,
43
                                ?Manager $scopePolicyManager = null)
44
    {
45
        parent::__construct($resourceOwnerProvider, $storageRepository, $configurationRepository,
0 ignored issues
show
Bug introduced by
It seems like $storageRepository defined by parameter $storageRepository on line 37 can be null; however, OAuth2\Server::__construct() does not accept null, maybe add an additional type check?

It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.

We recommend to add an additional type check (or disallow null for the parameter):

function notNullable(stdClass $x) { }

// Unsafe
function withoutCheck(stdClass $x = null) {
    notNullable($x);
}

// Safe - Alternative 1: Adding Additional Type-Check
function withCheck(stdClass $x = null) {
    if ($x instanceof stdClass) {
        notNullable($x);
    }
}

// Safe - Alternative 2: Changing Parameter
function withNonNullableParam(stdClass $x) {
    notNullable($x);
}
Loading history...
46
            $responseTypeRepository, $grantTypeRepository, $clientAuthenticatorRepository, $guard, $scopePolicyManager);
47
48
        $this->authorizationEndpoint = new AuthorizationEndpoint($this);
49
    }
50
51
    /**
52
     * @return \OAuth2\OpenID\Endpoints\AuthorizationEndpoint
53
     */
54
    public function getAuthorizationEndpoint(): \OAuth2\Endpoints\AuthorizationEndpoint
55
    {
56
        return $this->authorizationEndpoint;
57
    }
58
}