Completed
Push — master ( 30ef9c...66d5ad )
by
unknown
12s queued 11s
created

KycProofResult::__construct()   C

Complexity

Conditions 14
Paths 9

Size

Total Lines 51

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 51
rs 6.2666
c 0
b 0
f 0
cc 14
nc 9
nop 8

How to fix   Long Method    Complexity    Many Parameters   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
namespace Covery\Client;
4
5
/**
6
 * Class KycProofResult
7
 *
8
 * Contains keyProof result data, received from Covery
9
 *
10
 * @package Covery\Client
11
 */
12
class KycProofResult
13
{
14
    /**
15
     * @var int
16
     */
17
    private $requestId;
18
    /**
19
     * @var string
20
     */
21
    private $type;
22
    /**
23
     * @var int
24
     */
25
    private $createdAt;
26
    /**
27
     * @var string
28
     */
29
    private $verificationVideo;
30
    /**
31
     * @var string
32
     */
33
    private $faceProof;
34
    /**
35
     * @var string
36
     */
37
    private $documentProof;
38
    /**
39
     * @var string
40
     */
41
    private $documentTwoProof;
42
    /**
43
     * @var string
44
     */
45
    private $consentProof;
46
47
    /**
48
     * KycProofResult constructor.
49
     *
50
     * @param $requestId
51
     * @param $type
52
     * @param $createdAt
53
     * @param null|string $verificationVideo
54
     * @param null|string $faceProof
55
     * @param null|string $documentProof
56
     * @param null|string $documentTwoProof
57
     * @param null|string $consentProof
58
     */
59
    public function __construct(
60
        $requestId,
61
        $type,
62
        $createdAt,
63
        $verificationVideo = null,
64
        $faceProof = null,
65
        $documentProof = null,
66
        $documentTwoProof = null,
67
        $consentProof = null
68
69
    ) {
70
        if (!is_int($requestId)) {
71
            throw new \InvalidArgumentException('Request ID must be integer');
72
        }
73
74
        if (!is_string($type)) {
75
            throw new \InvalidArgumentException('Type must be string');
76
        }
77
78
        if (!is_int($createdAt)) {
79
            throw new \InvalidArgumentException('Created At must be integer');
80
        }
81
82
        if ($verificationVideo !== null && !is_string($verificationVideo)) {
83
            throw new \InvalidArgumentException('Verification Video must be string');
84
        }
85
86
        if ($faceProof !== null && !is_string($faceProof)) {
87
            throw new \InvalidArgumentException('Face Proof must be string');
88
        }
89
90
        if ($documentProof !== null && !is_string($documentProof)) {
91
            throw new \InvalidArgumentException('Document Proof must be string');
92
        }
93
94
        if ($documentTwoProof !== null && !is_string($documentTwoProof)) {
95
            throw new \InvalidArgumentException('Document Two Proof must be string');
96
        }
97
98
        if ($consentProof !== null && !is_string($consentProof)) {
99
            throw new \InvalidArgumentException('Consent Proof must be string');
100
        }
101
        $this->requestId = $requestId;
102
        $this->type = $type;
103
        $this->createdAt = $createdAt;
104
        $this->verificationVideo = $verificationVideo;
105
        $this->faceProof = $faceProof;
106
        $this->documentProof = $documentProof;
107
        $this->documentTwoProof = $documentTwoProof;
108
        $this->consentProof = $consentProof;
109
    }
110
111
    /**
112
     * @return int
113
     */
114
    public function getRequestId()
115
    {
116
        return $this->requestId;
117
    }
118
119
    /**
120
     * @return string
121
     */
122
    public function getType()
123
    {
124
        return $this->type;
125
    }
126
127
    /**
128
     * @return int
129
     */
130
    public function getCreatedAt()
131
    {
132
        return $this->createdAt;
133
    }
134
135
    /**
136
     * @return string|null
137
     */
138
    public function getVerificationVideo()
139
    {
140
        return $this->verificationVideo;
141
    }
142
143
    /**
144
     * @return string|null
145
     */
146
    public function getFaceProof()
147
    {
148
        return $this->faceProof;
149
    }
150
151
    /**
152
     * @return string|null
153
     */
154
    public function getDocumentProof()
155
    {
156
        return $this->documentProof;
157
    }
158
159
    /**
160
     * @return string|null
161
     */
162
    public function getDocumentTwoProof()
163
    {
164
        return $this->documentTwoProof;
165
    }
166
167
    /**
168
     * @return string|null
169
     */
170
    public function getConsentProof()
171
    {
172
        return $this->consentProof;
173
    }
174
175
176
}
177