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 |
||
| 8 | class UploadJobStatus extends UploadTicket |
||
| 9 | { |
||
| 10 | |||
| 11 | const PHASE_COMPLETED = 'completed'; |
||
| 12 | |||
| 13 | use HydratableTrait; |
||
| 14 | |||
| 15 | protected $phase; |
||
| 16 | protected $start_time; |
||
| 17 | protected $uploaded_time; |
||
| 18 | protected $validated_time; |
||
| 19 | protected $completed_time; |
||
| 20 | protected $error_code; |
||
| 21 | protected $time_to_process; |
||
| 22 | protected $percent_complete; |
||
| 23 | protected $num_valid; |
||
| 24 | protected $num_valid_user; |
||
| 25 | protected $num_invalid_format; |
||
| 26 | protected $num_invalid_user; |
||
| 27 | protected $num_invalid_segment; |
||
| 28 | protected $num_unauth_segment; |
||
| 29 | protected $num_past_expiration; |
||
| 30 | protected $num_inactive_segment; |
||
| 31 | protected $num_other_error; |
||
| 32 | protected $error_log_lines; |
||
| 33 | protected $segment_log_lines; |
||
| 34 | protected $created_on; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @return mixed |
||
| 38 | */ |
||
| 39 | public function getPhase() |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @param mixed $phase |
||
| 46 | */ |
||
| 47 | public function setPhase($phase) |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return mixed |
||
| 54 | */ |
||
| 55 | public function getStartTime() |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @param mixed $start_time |
||
| 62 | */ |
||
| 63 | public function setStartTime($start_time) |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @return mixed |
||
| 70 | */ |
||
| 71 | public function getUploadedTime() |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @param mixed $uploaded_time |
||
| 78 | */ |
||
| 79 | public function setUploadedTime($uploaded_time) |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @return mixed |
||
| 86 | */ |
||
| 87 | public function getValidatedTime() |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @param mixed $validated_time |
||
| 94 | */ |
||
| 95 | public function setValidatedTime($validated_time) |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @return mixed |
||
| 102 | */ |
||
| 103 | public function getCompletedTime() |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @param mixed $completed_time |
||
| 110 | */ |
||
| 111 | public function setCompletedTime($completed_time) |
||
| 115 | |||
| 116 | /** |
||
| 117 | * @return mixed |
||
| 118 | */ |
||
| 119 | public function getErrorCode() |
||
| 123 | |||
| 124 | /** |
||
| 125 | * @param mixed $error_code |
||
| 126 | */ |
||
| 127 | public function setErrorCode($error_code) |
||
| 131 | |||
| 132 | /** |
||
| 133 | * @return mixed |
||
| 134 | */ |
||
| 135 | public function getTimeToProcess() |
||
| 139 | |||
| 140 | /** |
||
| 141 | * @param mixed $time_to_process |
||
| 142 | */ |
||
| 143 | public function setTimeToProcess($time_to_process) |
||
| 147 | |||
| 148 | /** |
||
| 149 | * @return mixed |
||
| 150 | */ |
||
| 151 | public function getPercentComplete() |
||
| 155 | |||
| 156 | /** |
||
| 157 | * @param mixed $percent_complete |
||
| 158 | */ |
||
| 159 | public function setPercentComplete($percent_complete) |
||
| 163 | |||
| 164 | /** |
||
| 165 | * @return mixed |
||
| 166 | */ |
||
| 167 | public function getNumValid() |
||
| 171 | |||
| 172 | /** |
||
| 173 | * @param mixed $num_valid |
||
| 174 | */ |
||
| 175 | public function setNumValid($num_valid) |
||
| 179 | |||
| 180 | /** |
||
| 181 | * @return mixed |
||
| 182 | */ |
||
| 183 | public function getNumValidUser() |
||
| 187 | |||
| 188 | /** |
||
| 189 | * @param mixed $num_valid_user |
||
| 190 | */ |
||
| 191 | public function setNumValidUser($num_valid_user) |
||
| 195 | |||
| 196 | /** |
||
| 197 | * @return mixed |
||
| 198 | */ |
||
| 199 | public function getNumInvalidFormat() |
||
| 203 | |||
| 204 | /** |
||
| 205 | * @param mixed $num_invalid_format |
||
| 206 | */ |
||
| 207 | public function setNumInvalidFormat($num_invalid_format) |
||
| 211 | |||
| 212 | /** |
||
| 213 | * @return mixed |
||
| 214 | */ |
||
| 215 | public function getNumInvalidUser() |
||
| 219 | |||
| 220 | /** |
||
| 221 | * @param mixed $num_invalid_user |
||
| 222 | */ |
||
| 223 | public function setNumInvalidUser($num_invalid_user) |
||
| 227 | |||
| 228 | /** |
||
| 229 | * @return mixed |
||
| 230 | */ |
||
| 231 | public function getNumInvalidSegment() |
||
| 235 | |||
| 236 | /** |
||
| 237 | * @param mixed $num_invalid_segment |
||
| 238 | */ |
||
| 239 | public function setNumInvalidSegment($num_invalid_segment) |
||
| 243 | |||
| 244 | /** |
||
| 245 | * @return mixed |
||
| 246 | */ |
||
| 247 | public function getNumUnauthSegment() |
||
| 251 | |||
| 252 | /** |
||
| 253 | * @param mixed $num_unauth_segment |
||
| 254 | */ |
||
| 255 | public function setNumUnauthSegment($num_unauth_segment) |
||
| 259 | |||
| 260 | /** |
||
| 261 | * @return mixed |
||
| 262 | */ |
||
| 263 | public function getNumPastExpiration() |
||
| 267 | |||
| 268 | /** |
||
| 269 | * @param mixed $num_past_expiration |
||
| 270 | */ |
||
| 271 | public function setNumPastExpiration($num_past_expiration) |
||
| 275 | |||
| 276 | /** |
||
| 277 | * @return mixed |
||
| 278 | */ |
||
| 279 | public function getNumInactiveSegment() |
||
| 283 | |||
| 284 | /** |
||
| 285 | * @param mixed $num_inactive_segment |
||
| 286 | */ |
||
| 287 | public function setNumInactiveSegment($num_inactive_segment) |
||
| 291 | |||
| 292 | /** |
||
| 293 | * @return mixed |
||
| 294 | */ |
||
| 295 | public function getNumOtherError() |
||
| 299 | |||
| 300 | /** |
||
| 301 | * @param mixed $num_other_error |
||
| 302 | */ |
||
| 303 | public function setNumOtherError($num_other_error) |
||
| 307 | |||
| 308 | /** |
||
| 309 | * @return mixed |
||
| 310 | */ |
||
| 311 | public function getErrorLogLines() |
||
| 315 | |||
| 316 | /** |
||
| 317 | * @param mixed $error_log_lines |
||
| 318 | */ |
||
| 319 | public function setErrorLogLines($error_log_lines) |
||
| 323 | |||
| 324 | /** |
||
| 325 | * @return mixed |
||
| 326 | */ |
||
| 327 | public function getSegmentLogLines() |
||
| 331 | |||
| 332 | /** |
||
| 333 | * @param mixed $segment_log_lines |
||
| 334 | */ |
||
| 335 | public function setSegmentLogLines($segment_log_lines) |
||
| 339 | |||
| 340 | /** |
||
| 341 | * @return mixed |
||
| 342 | */ |
||
| 343 | public function getId() |
||
| 347 | |||
| 348 | /** |
||
| 349 | * @param mixed $id |
||
| 350 | */ |
||
| 351 | public function setId($id) |
||
| 355 | |||
| 356 | /** |
||
| 357 | * @return mixed |
||
| 358 | */ |
||
| 359 | public function getJobId() |
||
| 363 | |||
| 364 | /** |
||
| 365 | * @param mixed $job_id |
||
| 366 | */ |
||
| 367 | public function setJobId($job_id) |
||
| 371 | |||
| 372 | /** |
||
| 373 | * @return mixed |
||
| 374 | */ |
||
| 375 | public function getMemberId() |
||
| 379 | |||
| 380 | /** |
||
| 381 | * @param mixed $member_id |
||
| 382 | */ |
||
| 383 | public function setMemberId($member_id) |
||
| 387 | |||
| 388 | /** |
||
| 389 | * @return mixed |
||
| 390 | */ |
||
| 391 | public function getCreatedOn() |
||
| 395 | |||
| 396 | /** |
||
| 397 | * @param mixed $created_on |
||
| 398 | */ |
||
| 399 | public function setCreatedOn($created_on) |
||
| 403 | |||
| 404 | /** |
||
| 405 | * @return mixed |
||
| 406 | */ |
||
| 407 | public function getLastModified() |
||
| 411 | |||
| 412 | /** |
||
| 413 | * @param mixed $last_modified |
||
| 414 | */ |
||
| 415 | public function setLastModified($last_modified) |
||
| 419 | |||
| 420 | /** |
||
| 421 | * @return bool |
||
| 422 | */ |
||
| 423 | public function isCompeted() |
||
| 427 | |||
| 428 | /** |
||
| 429 | * @param array $objectArray |
||
| 430 | * |
||
| 431 | * @return UploadJobStatus |
||
| 432 | */ |
||
| 433 | public static function fromArray(array $objectArray) |
||
| 445 | } |
||
| 446 |