Complex classes like SendSmsResponse 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 SendSmsResponse, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
7 | class SendSmsResponse |
||
8 | { |
||
9 | |||
10 | public $id; |
||
11 | public $phone_id; |
||
12 | public $contact_id; |
||
13 | public $direction; |
||
14 | public $status; |
||
15 | public $message_type; |
||
16 | public $source; |
||
17 | public $time_created; |
||
18 | public $time_sent; |
||
19 | public $time_updated; |
||
20 | public $from_number; |
||
21 | public $to_number; |
||
22 | public $content; |
||
23 | public $starred; |
||
24 | public $simulated; |
||
25 | public $track_clicks; |
||
26 | public $vars; |
||
27 | public $external_id; |
||
28 | public $label_ids; |
||
29 | public $route_id; |
||
30 | public $scheduled_id; |
||
31 | public $broadcast_id; |
||
32 | public $service_id; |
||
33 | public $user_id; |
||
34 | public $project_id; |
||
35 | public $priority; |
||
36 | |||
37 | |||
38 | |||
39 | |||
40 | /** |
||
41 | * SendSmsResponse constructor. |
||
42 | * @param $id |
||
43 | * @param $phone_id |
||
44 | * @param $contact_id |
||
45 | * @param $direction |
||
46 | * @param $status |
||
47 | * @param $message_type |
||
48 | * @param $source |
||
49 | * @param $time_created |
||
50 | * @param $time_sent |
||
51 | * @param $time_updated |
||
52 | * @param $from_number |
||
53 | * @param $to_number |
||
54 | * @param $content |
||
55 | * @param $starred |
||
56 | * @param $simulated |
||
57 | * @param $track_clicks |
||
58 | * @param $vars |
||
59 | * @param $external_id |
||
60 | * @param $label_ids |
||
61 | * @param $route_id |
||
62 | * @param $scheduled_id |
||
63 | * @param $broadcast_id |
||
64 | * @param $service_id |
||
65 | * @param $user_id |
||
66 | * @param $project_id |
||
67 | * @param $priority |
||
68 | */ |
||
69 | public function __construct($id, $phone_id, $contact_id, $direction, $status, $message_type, $source, $time_created, $time_sent, $time_updated, $from_number, $to_number, $content, $starred, $simulated, $track_clicks, $vars, $external_id, $label_ids, $route_id, $scheduled_id, $broadcast_id, $service_id, $user_id, $project_id, $priority) |
||
98 | |||
99 | /** |
||
100 | * @return mixed |
||
101 | */ |
||
102 | public function getId() |
||
106 | |||
107 | /** |
||
108 | * @param mixed $id |
||
109 | */ |
||
110 | public function setId($id): void |
||
114 | |||
115 | /** |
||
116 | * @return mixed |
||
117 | */ |
||
118 | public function getPhoneId() |
||
122 | |||
123 | /** |
||
124 | * @param mixed $phone_id |
||
125 | */ |
||
126 | public function setPhoneId($phone_id): void |
||
130 | |||
131 | /** |
||
132 | * @return mixed |
||
133 | */ |
||
134 | public function getContactId() |
||
138 | |||
139 | /** |
||
140 | * @param mixed $contact_id |
||
141 | */ |
||
142 | public function setContactId($contact_id): void |
||
146 | |||
147 | /** |
||
148 | * @return mixed |
||
149 | */ |
||
150 | public function getDirection() |
||
154 | |||
155 | /** |
||
156 | * @param mixed $direction |
||
157 | */ |
||
158 | public function setDirection($direction): void |
||
162 | |||
163 | /** |
||
164 | * @return mixed |
||
165 | */ |
||
166 | public function getStatus() |
||
170 | |||
171 | /** |
||
172 | * @param mixed $status |
||
173 | */ |
||
174 | public function setStatus($status): void |
||
178 | |||
179 | /** |
||
180 | * @return mixed |
||
181 | */ |
||
182 | public function getMessageType() |
||
186 | |||
187 | /** |
||
188 | * @param mixed $message_type |
||
189 | */ |
||
190 | public function setMessageType($message_type): void |
||
194 | |||
195 | /** |
||
196 | * @return mixed |
||
197 | */ |
||
198 | public function getSource() |
||
202 | |||
203 | /** |
||
204 | * @param mixed $source |
||
205 | */ |
||
206 | public function setSource($source): void |
||
210 | |||
211 | /** |
||
212 | * @return mixed |
||
213 | */ |
||
214 | public function getTimeCreated() |
||
218 | |||
219 | /** |
||
220 | * @param mixed $time_created |
||
221 | */ |
||
222 | public function setTimeCreated($time_created): void |
||
226 | |||
227 | /** |
||
228 | * @return mixed |
||
229 | */ |
||
230 | public function getTimeSent() |
||
234 | |||
235 | /** |
||
236 | * @param mixed $time_sent |
||
237 | */ |
||
238 | public function setTimeSent($time_sent): void |
||
242 | |||
243 | /** |
||
244 | * @return mixed |
||
245 | */ |
||
246 | public function getTimeUpdated() |
||
250 | |||
251 | /** |
||
252 | * @param mixed $time_updated |
||
253 | */ |
||
254 | public function setTimeUpdated($time_updated): void |
||
258 | |||
259 | /** |
||
260 | * @return mixed |
||
261 | */ |
||
262 | public function getFromNumber() |
||
266 | |||
267 | /** |
||
268 | * @param mixed $from_number |
||
269 | */ |
||
270 | public function setFromNumber($from_number): void |
||
274 | |||
275 | /** |
||
276 | * @return mixed |
||
277 | */ |
||
278 | public function getToNumber() |
||
282 | |||
283 | /** |
||
284 | * @param mixed $to_number |
||
285 | */ |
||
286 | public function setToNumber($to_number): void |
||
290 | |||
291 | /** |
||
292 | * @return mixed |
||
293 | */ |
||
294 | public function getContent() |
||
298 | |||
299 | /** |
||
300 | * @param mixed $content |
||
301 | */ |
||
302 | public function setContent($content): void |
||
306 | |||
307 | /** |
||
308 | * @return mixed |
||
309 | */ |
||
310 | public function getStarred() |
||
314 | |||
315 | /** |
||
316 | * @param mixed $starred |
||
317 | */ |
||
318 | public function setStarred($starred): void |
||
322 | |||
323 | /** |
||
324 | * @return mixed |
||
325 | */ |
||
326 | public function getSimulated() |
||
330 | |||
331 | /** |
||
332 | * @param mixed $simulated |
||
333 | */ |
||
334 | public function setSimulated($simulated): void |
||
338 | |||
339 | /** |
||
340 | * @return mixed |
||
341 | */ |
||
342 | public function getTrackClicks() |
||
346 | |||
347 | /** |
||
348 | * @param mixed $track_clicks |
||
349 | */ |
||
350 | public function setTrackClicks($track_clicks): void |
||
354 | |||
355 | /** |
||
356 | * @return mixed |
||
357 | */ |
||
358 | public function getVars() |
||
362 | |||
363 | /** |
||
364 | * @param mixed $vars |
||
365 | */ |
||
366 | public function setVars($vars): void |
||
370 | |||
371 | /** |
||
372 | * @return mixed |
||
373 | */ |
||
374 | public function getExternalId() |
||
378 | |||
379 | /** |
||
380 | * @param mixed $external_id |
||
381 | */ |
||
382 | public function setExternalId($external_id): void |
||
386 | |||
387 | /** |
||
388 | * @return mixed |
||
389 | */ |
||
390 | public function getLabelIds() |
||
394 | |||
395 | /** |
||
396 | * @param mixed $label_ids |
||
397 | */ |
||
398 | public function setLabelIds($label_ids): void |
||
402 | |||
403 | /** |
||
404 | * @return mixed |
||
405 | */ |
||
406 | public function getRouteId() |
||
410 | |||
411 | /** |
||
412 | * @param mixed $route_id |
||
413 | */ |
||
414 | public function setRouteId($route_id): void |
||
418 | |||
419 | /** |
||
420 | * @return mixed |
||
421 | */ |
||
422 | public function getScheduledId() |
||
426 | |||
427 | /** |
||
428 | * @param mixed $scheduled_id |
||
429 | */ |
||
430 | public function setScheduledId($scheduled_id): void |
||
434 | |||
435 | /** |
||
436 | * @return mixed |
||
437 | */ |
||
438 | public function getBroadcastId() |
||
442 | |||
443 | /** |
||
444 | * @param mixed $broadcast_id |
||
445 | */ |
||
446 | public function setBroadcastId($broadcast_id): void |
||
450 | |||
451 | /** |
||
452 | * @return mixed |
||
453 | */ |
||
454 | public function getServiceId() |
||
458 | |||
459 | /** |
||
460 | * @param mixed $service_id |
||
461 | */ |
||
462 | public function setServiceId($service_id): void |
||
466 | |||
467 | /** |
||
468 | * @return mixed |
||
469 | */ |
||
470 | public function getUserId() |
||
474 | |||
475 | /** |
||
476 | * @param mixed $user_id |
||
477 | */ |
||
478 | public function setUserId($user_id): void |
||
482 | |||
483 | /** |
||
484 | * @return mixed |
||
485 | */ |
||
486 | public function getProjectId() |
||
490 | |||
491 | /** |
||
492 | * @param mixed $project_id |
||
493 | */ |
||
494 | public function setProjectId($project_id): void |
||
498 | |||
499 | /** |
||
500 | * @return mixed |
||
501 | */ |
||
502 | public function getPriority() |
||
506 | |||
507 | /** |
||
508 | * @param mixed $priority |
||
509 | */ |
||
510 | public function setPriority($priority): void |
||
514 | |||
515 | |||
516 | |||
517 | } |
||
518 |