Complex classes like CreateMeetingParameters 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 CreateMeetingParameters, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
24 | class CreateMeetingParameters extends MetaParameters |
||
25 | { |
||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private $meetingId; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $meetingName; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | private $attendeePassword; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | private $moderatorPassword; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | private $dialNumber; |
||
50 | |||
51 | /** |
||
52 | * @var int |
||
53 | */ |
||
54 | private $voiceBridge; |
||
55 | |||
56 | /** |
||
57 | * @var string |
||
58 | */ |
||
59 | private $webVoice; |
||
60 | |||
61 | /** |
||
62 | * @var string |
||
63 | */ |
||
64 | private $logoutUrl; |
||
65 | |||
66 | /** |
||
67 | * @var int |
||
68 | */ |
||
69 | private $maxParticipants; |
||
70 | |||
71 | /** |
||
72 | * @var bool |
||
73 | */ |
||
74 | private $record; |
||
75 | |||
76 | /** |
||
77 | * @var bool |
||
78 | */ |
||
79 | private $autoStartRecording; |
||
80 | |||
81 | /** |
||
82 | * @var bool |
||
83 | */ |
||
84 | private $allowStartStopRecording; |
||
85 | |||
86 | /** |
||
87 | * @var int |
||
88 | */ |
||
89 | private $duration; |
||
90 | |||
91 | /** |
||
92 | * @var string |
||
93 | */ |
||
94 | private $welcomeMessage; |
||
95 | |||
96 | /** |
||
97 | * @var string |
||
98 | */ |
||
99 | private $moderatorOnlyMessage; |
||
100 | |||
101 | /** |
||
102 | * @var string |
||
103 | */ |
||
104 | private $logo; |
||
105 | |||
106 | /** |
||
107 | * @var string |
||
108 | */ |
||
109 | private $copyright; |
||
110 | |||
111 | /** |
||
112 | * @var bool |
||
113 | */ |
||
114 | private $muteOnStart; |
||
115 | |||
116 | /** |
||
117 | * @var array |
||
118 | */ |
||
119 | private $presentations = []; |
||
120 | |||
121 | /** |
||
122 | * CreateMeetingParameters constructor. |
||
123 | * |
||
124 | * @param $meetingId |
||
125 | * @param $meetingName |
||
126 | */ |
||
127 | public function __construct($meetingId, $meetingName) |
||
132 | |||
133 | /** |
||
134 | * @return string |
||
135 | */ |
||
136 | public function getMeetingId() |
||
140 | |||
141 | /** |
||
142 | * @param string $meetingId |
||
143 | * |
||
144 | * @return CreateMeetingParameters |
||
145 | */ |
||
146 | public function setMeetingId($meetingId) |
||
152 | |||
153 | /** |
||
154 | * @return string |
||
155 | */ |
||
156 | public function getMeetingName() |
||
160 | |||
161 | /** |
||
162 | * @param string $meetingName |
||
163 | * |
||
164 | * @return CreateMeetingParameters |
||
165 | */ |
||
166 | public function setMeetingName($meetingName) |
||
172 | |||
173 | /** |
||
174 | * @return string |
||
175 | */ |
||
176 | public function getAttendeePassword() |
||
180 | |||
181 | /** |
||
182 | * @param string $attendeePassword |
||
183 | * |
||
184 | * @return CreateMeetingParameters |
||
185 | */ |
||
186 | public function setAttendeePassword($attendeePassword) |
||
192 | |||
193 | /** |
||
194 | * @return string |
||
195 | */ |
||
196 | public function getModeratorPassword() |
||
200 | |||
201 | /** |
||
202 | * @param string $moderatorPassword |
||
203 | * |
||
204 | * @return CreateMeetingParameters |
||
205 | */ |
||
206 | public function setModeratorPassword($moderatorPassword) |
||
212 | |||
213 | /** |
||
214 | * @return string |
||
215 | */ |
||
216 | public function getDialNumber() |
||
220 | |||
221 | /** |
||
222 | * @param string $dialNumber |
||
223 | * |
||
224 | * @return CreateMeetingParameters |
||
225 | */ |
||
226 | public function setDialNumber($dialNumber) |
||
232 | |||
233 | /** |
||
234 | * @return int |
||
235 | */ |
||
236 | public function getVoiceBridge() |
||
240 | |||
241 | /** |
||
242 | * @param int $voiceBridge |
||
243 | * |
||
244 | * @return CreateMeetingParameters |
||
245 | */ |
||
246 | public function setVoiceBridge($voiceBridge) |
||
252 | |||
253 | /** |
||
254 | * @return string |
||
255 | */ |
||
256 | public function getWebVoice() |
||
260 | |||
261 | /** |
||
262 | * @param string $webVoice |
||
263 | * |
||
264 | * @return CreateMeetingParameters |
||
265 | */ |
||
266 | public function setWebVoice($webVoice) |
||
272 | |||
273 | /** |
||
274 | * @return string |
||
275 | */ |
||
276 | public function getLogoutUrl() |
||
280 | |||
281 | /** |
||
282 | * @param string $logoutUrl |
||
283 | * |
||
284 | * @return CreateMeetingParameters |
||
285 | */ |
||
286 | public function setLogoutUrl($logoutUrl) |
||
292 | |||
293 | /** |
||
294 | * @return int |
||
295 | */ |
||
296 | public function getMaxParticipants() |
||
300 | |||
301 | /** |
||
302 | * @param int $maxParticipants |
||
303 | * |
||
304 | * @return CreateMeetingParameters |
||
305 | */ |
||
306 | public function setMaxParticipants($maxParticipants) |
||
312 | |||
313 | /** |
||
314 | * @return bool |
||
315 | */ |
||
316 | public function isRecorded() |
||
320 | |||
321 | /** |
||
322 | * @param bool $record |
||
323 | * |
||
324 | * @return CreateMeetingParameters |
||
325 | */ |
||
326 | public function setRecord($record) |
||
332 | |||
333 | /** |
||
334 | * @return bool |
||
335 | */ |
||
336 | public function isAutoStartRecording() |
||
340 | |||
341 | /** |
||
342 | * @param bool $autoStartRecording |
||
343 | * |
||
344 | * @return CreateMeetingParameters |
||
345 | */ |
||
346 | public function setAutoStartRecording($autoStartRecording) |
||
352 | |||
353 | /** |
||
354 | * @return bool |
||
355 | */ |
||
356 | public function isAllowStartStopRecording() |
||
360 | |||
361 | /** |
||
362 | * @param bool $autoStartRecording |
||
363 | * |
||
364 | * @return CreateMeetingParameters |
||
365 | */ |
||
366 | public function setAllowStartStopRecording($autoStartRecording) |
||
372 | |||
373 | /** |
||
374 | * @return int |
||
375 | */ |
||
376 | public function getDuration() |
||
380 | |||
381 | /** |
||
382 | * @param int $duration |
||
383 | * |
||
384 | * @return CreateMeetingParameters |
||
385 | */ |
||
386 | public function setDuration($duration) |
||
392 | |||
393 | /** |
||
394 | * @return string |
||
395 | */ |
||
396 | public function getWelcomeMessage() |
||
400 | |||
401 | /** |
||
402 | * @param string $welcomeMessage |
||
403 | * |
||
404 | * @return CreateMeetingParameters |
||
405 | */ |
||
406 | public function setWelcomeMessage($welcomeMessage) |
||
412 | |||
413 | /** |
||
414 | * @return string |
||
415 | */ |
||
416 | public function getModeratorOnlyMessage() |
||
420 | |||
421 | /** |
||
422 | * @param string $message |
||
423 | * |
||
424 | * @return CreateMeetingParameters |
||
425 | */ |
||
426 | public function setModeratorOnlyMessage($message) |
||
432 | |||
433 | /** |
||
434 | * @return string |
||
435 | */ |
||
436 | public function getLogo() |
||
440 | |||
441 | /** |
||
442 | * @param string $message |
||
|
|||
443 | * |
||
444 | * @return CreateMeetingParameters |
||
445 | */ |
||
446 | public function setLogo($url) |
||
452 | |||
453 | /** |
||
454 | * @return string |
||
455 | */ |
||
456 | public function getCopyright() |
||
460 | |||
461 | /** |
||
462 | * @param string $message |
||
463 | * |
||
464 | * @return CreateMeetingParameters |
||
465 | */ |
||
466 | public function setCopyright($string) |
||
472 | |||
473 | /** |
||
474 | * @return bool |
||
475 | */ |
||
476 | public function isMuteOnStart() |
||
480 | |||
481 | /** |
||
482 | * @param bool $muteOnStart |
||
483 | * |
||
484 | * @return CreateMeetingParameters |
||
485 | */ |
||
486 | public function setMuteOnStart($muteOnStart) |
||
492 | |||
493 | /** |
||
494 | * @return array |
||
495 | */ |
||
496 | public function getPresentations() |
||
500 | |||
501 | /** |
||
502 | * @param $nameOrUrl |
||
503 | * @param null $content |
||
504 | * |
||
505 | * @return CreateMeetingParameters |
||
506 | */ |
||
507 | public function addPresentation($nameOrUrl, $content = null) |
||
513 | |||
514 | public function getPresentationsAsXML() |
||
537 | |||
538 | /** |
||
539 | * @return string |
||
540 | */ |
||
541 | public function getHTTPQuery() |
||
568 | } |
||
569 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.