Passed
Push — master ( fd01cd...a8d522 )
by Alexandre
02:26
created

AuthorizationCode::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 9
dl 0
loc 7
rs 9.4285
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: 07/03/2018
6
 * Time: 21:57
7
 */
8
9
namespace OAuth2\Extensions\PKCE\Credentials;
10
11
12
class AuthorizationCode extends \OAuth2\Credentials\AuthorizationCode
13
{
14
    /**
15
     * @var string|null
16
     */
17
    protected $codeChallenge;
18
    /**
19
     * @var string|null
20
     */
21
    protected $codeChallengeMethod;
22
23
    public function __construct(string $code, string $scope, string $clientIdentifier, string $resourceOwnerIdentifier,
24
                                int $expiresAt, ?string $requestedScope = null, ?string $redirectUri = null,
25
                                ?string $codeChallenge = null, ?string $codeChallengeMethod = null)
26
    {
27
       parent::__construct($code, $scope, $clientIdentifier, $resourceOwnerIdentifier, $expiresAt, $requestedScope, $redirectUri);
28
        $this->codeChallenge = $codeChallenge;
29
        $this->codeChallengeMethod = $codeChallengeMethod;
30
    }
31
32
    /**
33
     * @return null|string
34
     */
35
    public function getCodeChallenge(): ?string
36
    {
37
        return $this->codeChallenge;
38
    }
39
40
    /**
41
     * @param null|string $codeChallenge
42
     */
43
    public function setCodeChallenge(?string $codeChallenge): void
44
    {
45
        $this->codeChallenge = $codeChallenge;
46
    }
47
48
    /**
49
     * @return null|string
50
     */
51
    public function getCodeChallengeMethod(): ?string
52
    {
53
        return $this->codeChallengeMethod;
54
    }
55
56
    /**
57
     * @param null|string $codeChallengeMethod
58
     */
59
    public function setCodeChallengeMethod(?string $codeChallengeMethod): void
60
    {
61
        $this->codeChallengeMethod = $codeChallengeMethod;
62
    }
63
}