UploadJobStatus   B
last analyzed

Complexity

Total Complexity 51

Size/Duplication

Total Lines 286
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 51
lcom 1
cbo 3
dl 0
loc 286
rs 7.92
c 0
b 0
f 0

50 Methods

Rating   Name   Duplication   Size   Complexity  
A getPhase() 0 4 1
A setPhase() 0 4 1
A getStartTime() 0 4 1
A setStartTime() 0 4 1
A getUploadedTime() 0 4 1
A setUploadedTime() 0 4 1
A getValidatedTime() 0 4 1
A setValidatedTime() 0 4 1
A getCompletedTime() 0 4 1
A setCompletedTime() 0 4 1
A getErrorCode() 0 4 1
A setErrorCode() 0 4 1
A getTimeToProcess() 0 4 1
A setTimeToProcess() 0 4 1
A getPercentComplete() 0 4 1
A setPercentComplete() 0 4 1
A getNumValid() 0 4 1
A setNumValid() 0 4 1
A getNumValidUser() 0 4 1
A setNumValidUser() 0 4 1
A getNumInvalidFormat() 0 4 1
A setNumInvalidFormat() 0 4 1
A getNumInvalidUser() 0 4 1
A setNumInvalidUser() 0 4 1
A getNumInvalidSegment() 0 4 1
A setNumInvalidSegment() 0 4 1
A getNumUnauthSegment() 0 4 1
A setNumUnauthSegment() 0 4 1
A getNumPastExpiration() 0 4 1
A setNumPastExpiration() 0 4 1
A getNumInactiveSegment() 0 4 1
A setNumInactiveSegment() 0 4 1
A getNumOtherError() 0 4 1
A setNumOtherError() 0 4 1
A getErrorLogLines() 0 4 1
A setErrorLogLines() 0 4 1
A getSegmentLogLines() 0 4 1
A setSegmentLogLines() 0 4 1
A getId() 0 4 1
A setId() 0 4 1
A getJobId() 0 4 1
A setJobId() 0 4 1
A getMemberId() 0 4 1
A setMemberId() 0 4 1
A getCreatedOn() 0 4 1
A setCreatedOn() 0 4 1
A getLastModified() 0 4 1
A setLastModified() 0 4 1
A isCompeted() 0 4 1
A fromArray() 0 12 2

How to fix   Complexity   

Complex Class

Complex classes like UploadJobStatus often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use UploadJobStatus, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace Audiens\AppnexusClient\entity;
4
5
class UploadJobStatus extends UploadTicket
6
{
7
8
    public const PHASE_COMPLETED = 'completed';
9
10
    use HydratableTrait;
11
12
    protected $phase;
13
    protected $start_time;
14
    protected $uploaded_time;
15
    protected $validated_time;
16
    protected $completed_time;
17
    protected $error_code;
18
    protected $time_to_process;
19
    protected $percent_complete;
20
    protected $num_valid;
21
    protected $num_valid_user;
22
    protected $num_invalid_format;
23
    protected $num_invalid_user;
24
    protected $num_invalid_segment;
25
    protected $num_unauth_segment;
26
    protected $num_past_expiration;
27
    protected $num_inactive_segment;
28
    protected $num_other_error;
29
    protected $error_log_lines;
30
    protected $segment_log_lines;
31
    protected $created_on;
32
33
    public function getPhase()
34
    {
35
        return $this->phase;
36
    }
37
38
    public function setPhase($phase)
39
    {
40
        $this->phase = $phase;
41
    }
42
43
    public function getStartTime()
44
    {
45
        return $this->start_time;
46
    }
47
48
    public function setStartTime($start_time)
49
    {
50
        $this->start_time = $start_time;
51
    }
52
53
    public function getUploadedTime()
54
    {
55
        return $this->uploaded_time;
56
    }
57
58
    public function setUploadedTime($uploaded_time)
59
    {
60
        $this->uploaded_time = $uploaded_time;
61
    }
62
63
    public function getValidatedTime()
64
    {
65
        return $this->validated_time;
66
    }
67
68
    public function setValidatedTime($validated_time)
69
    {
70
        $this->validated_time = $validated_time;
71
    }
72
73
    public function getCompletedTime()
74
    {
75
        return $this->completed_time;
76
    }
77
78
    public function setCompletedTime($completed_time)
79
    {
80
        $this->completed_time = $completed_time;
81
    }
82
83
    public function getErrorCode()
84
    {
85
        return $this->error_code;
86
    }
87
88
    public function setErrorCode($error_code)
89
    {
90
        $this->error_code = $error_code;
91
    }
92
93
    public function getTimeToProcess()
94
    {
95
        return $this->time_to_process;
96
    }
97
98
    public function setTimeToProcess($time_to_process)
99
    {
100
        $this->time_to_process = $time_to_process;
101
    }
102
103
    public function getPercentComplete()
104
    {
105
        return $this->percent_complete;
106
    }
107
108
    public function setPercentComplete($percent_complete)
109
    {
110
        $this->percent_complete = $percent_complete;
111
    }
112
113
    public function getNumValid()
114
    {
115
        return $this->num_valid;
116
    }
117
118
    public function setNumValid($num_valid)
119
    {
120
        $this->num_valid = $num_valid;
121
    }
122
123
    public function getNumValidUser()
124
    {
125
        return $this->num_valid_user;
126
    }
127
128
    public function setNumValidUser($num_valid_user)
129
    {
130
        $this->num_valid_user = $num_valid_user;
131
    }
132
133
    public function getNumInvalidFormat()
134
    {
135
        return $this->num_invalid_format;
136
    }
137
138
    public function setNumInvalidFormat($num_invalid_format)
139
    {
140
        $this->num_invalid_format = $num_invalid_format;
141
    }
142
143
    public function getNumInvalidUser()
144
    {
145
        return $this->num_invalid_user;
146
    }
147
148
    public function setNumInvalidUser($num_invalid_user)
149
    {
150
        $this->num_invalid_user = $num_invalid_user;
151
    }
152
153
    public function getNumInvalidSegment()
154
    {
155
        return $this->num_invalid_segment;
156
    }
157
158
    public function setNumInvalidSegment($num_invalid_segment)
159
    {
160
        $this->num_invalid_segment = $num_invalid_segment;
161
    }
162
163
    public function getNumUnauthSegment()
164
    {
165
        return $this->num_unauth_segment;
166
    }
167
168
    public function setNumUnauthSegment($num_unauth_segment)
169
    {
170
        $this->num_unauth_segment = $num_unauth_segment;
171
    }
172
173
    public function getNumPastExpiration()
174
    {
175
        return $this->num_past_expiration;
176
    }
177
178
    public function setNumPastExpiration($num_past_expiration)
179
    {
180
        $this->num_past_expiration = $num_past_expiration;
181
    }
182
183
    public function getNumInactiveSegment()
184
    {
185
        return $this->num_inactive_segment;
186
    }
187
188
    public function setNumInactiveSegment($num_inactive_segment)
189
    {
190
        $this->num_inactive_segment = $num_inactive_segment;
191
    }
192
193
    public function getNumOtherError()
194
    {
195
        return $this->num_other_error;
196
    }
197
198
    public function setNumOtherError($num_other_error)
199
    {
200
        $this->num_other_error = $num_other_error;
201
    }
202
203
    public function getErrorLogLines()
204
    {
205
        return $this->error_log_lines;
206
    }
207
208
    public function setErrorLogLines($error_log_lines)
209
    {
210
        $this->error_log_lines = $error_log_lines;
211
    }
212
213
    public function getSegmentLogLines()
214
    {
215
        return $this->segment_log_lines;
216
    }
217
218
    public function setSegmentLogLines($segment_log_lines)
219
    {
220
        $this->segment_log_lines = $segment_log_lines;
221
    }
222
223
    public function getId()
224
    {
225
        return $this->id;
226
    }
227
228
    public function setId($id)
229
    {
230
        $this->id = $id;
231
    }
232
233
    public function getJobId()
234
    {
235
        return $this->job_id;
236
    }
237
238
    public function setJobId($job_id)
239
    {
240
        $this->job_id = $job_id;
241
    }
242
243
    public function getMemberId()
244
    {
245
        return $this->member_id;
246
    }
247
248
    public function setMemberId($member_id)
249
    {
250
        $this->member_id = $member_id;
251
    }
252
253
    public function getCreatedOn()
254
    {
255
        return $this->created_on;
256
    }
257
258
    public function setCreatedOn($created_on)
259
    {
260
        $this->created_on = $created_on;
261
    }
262
263
    public function getLastModified()
264
    {
265
        return $this->last_modified;
266
    }
267
268
    public function setLastModified($last_modified)
269
    {
270
        $this->last_modified = $last_modified;
271
    }
272
273
    public function isCompeted(): bool
274
    {
275
        return $this->phase == self::PHASE_COMPLETED;
276
    }
277
278
    public static function fromArray(array $objectArray)
279
    {
280
        $object = new self();
281
282
        if (!isset($objectArray['upload_url'])) {
283
            $objectArray['upload_url'] = '';
284
        }
285
286
        self::getHydrator()->hydrate($objectArray, $object);
287
288
        return $object;
289
    }
290
}
291