Complex classes like BigBlueButton 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 BigBlueButton, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
56 | class BigBlueButton |
||
57 | { |
||
58 | protected $securitySecret; |
||
59 | protected $bbbServerBaseUrl; |
||
60 | protected $urlBuilder; |
||
61 | protected $jSessionId; |
||
62 | |||
63 | public function __construct() |
||
70 | |||
71 | /** |
||
72 | * @return ApiVersionResponse |
||
73 | * |
||
74 | * @throws \RuntimeException |
||
75 | */ |
||
76 | public function getApiVersion() |
||
82 | |||
83 | /* __________________ BBB ADMINISTRATION METHODS _________________ */ |
||
84 | /* The methods in the following section support the following categories of the BBB API: |
||
85 | -- create |
||
86 | -- getDefaultConfigXML |
||
87 | -- setConfigXML |
||
88 | -- join |
||
89 | -- end |
||
90 | */ |
||
91 | |||
92 | /** |
||
93 | * @param CreateMeetingParameters $createMeetingParams |
||
94 | * @return string |
||
95 | */ |
||
96 | public function getCreateMeetingUrl($createMeetingParams) |
||
100 | |||
101 | /** |
||
102 | * @param CreateMeetingParameters $createMeetingParams |
||
103 | * @return CreateMeetingResponse |
||
104 | * @throws \RuntimeException |
||
105 | */ |
||
106 | public function createMeeting($createMeetingParams) |
||
112 | |||
113 | /** |
||
114 | * @return string |
||
115 | */ |
||
116 | public function getDefaultConfigXMLUrl() |
||
120 | |||
121 | /** |
||
122 | * @return GetDefaultConfigXMLResponse |
||
123 | * @throws \RuntimeException |
||
124 | */ |
||
125 | public function getDefaultConfigXML() |
||
131 | |||
132 | /** |
||
133 | * @return string |
||
134 | */ |
||
135 | public function setConfigXMLUrl() |
||
139 | |||
140 | /** |
||
141 | * @param $setConfigXMLParams |
||
142 | * @return SetConfigXMLResponse |
||
143 | * @throws \RuntimeException |
||
144 | */ |
||
145 | public function setConfigXML($setConfigXMLParams) |
||
153 | |||
154 | /** |
||
155 | * @param $joinMeetingParams JoinMeetingParameters |
||
156 | * |
||
157 | * @return string |
||
158 | */ |
||
159 | public function getJoinMeetingURL($joinMeetingParams) |
||
163 | |||
164 | /** |
||
165 | * @param $joinMeetingParams JoinMeetingParameters |
||
166 | * |
||
167 | * @return JoinMeetingResponse |
||
168 | * @throws \RuntimeException |
||
169 | */ |
||
170 | public function joinMeeting($joinMeetingParams) |
||
176 | |||
177 | /** |
||
178 | * @param $endParams EndMeetingParameters |
||
179 | * |
||
180 | * @return string |
||
181 | */ |
||
182 | public function getEndMeetingURL($endParams) |
||
186 | |||
187 | /** |
||
188 | * @param $endParams EndMeetingParameters |
||
189 | * |
||
190 | * @return EndMeetingResponse |
||
191 | * @throws \RuntimeException |
||
192 | * */ |
||
193 | public function endMeeting($endParams) |
||
199 | |||
200 | /* __________________ BBB MONITORING METHODS _________________ */ |
||
201 | /* The methods in the following section support the following categories of the BBB API: |
||
202 | -- isMeetingRunning |
||
203 | -- getMeetings |
||
204 | -- getMeetingInfo |
||
205 | */ |
||
206 | |||
207 | /** |
||
208 | * @param $meetingParams IsMeetingRunningParameters |
||
209 | * @return string |
||
210 | */ |
||
211 | public function getIsMeetingRunningUrl($meetingParams) |
||
215 | |||
216 | /** |
||
217 | * @param $meetingParams |
||
218 | * @return IsMeetingRunningResponse |
||
219 | * @throws \RuntimeException |
||
220 | */ |
||
221 | public function isMeetingRunning($meetingParams) |
||
227 | |||
228 | /** |
||
229 | * @return string |
||
230 | */ |
||
231 | public function getMeetingsUrl() |
||
235 | |||
236 | /** |
||
237 | * @return GetMeetingsResponse |
||
238 | * @throws \RuntimeException |
||
239 | */ |
||
240 | public function getMeetings() |
||
246 | |||
247 | /** |
||
248 | * @param $meetingParams GetMeetingInfoParameters |
||
249 | * @return string |
||
250 | */ |
||
251 | public function getMeetingInfoUrl($meetingParams) |
||
255 | |||
256 | /** |
||
257 | * @param $meetingParams GetMeetingInfoParameters |
||
258 | * @return GetMeetingInfoResponse |
||
259 | * @throws \RuntimeException |
||
260 | */ |
||
261 | public function getMeetingInfo($meetingParams) |
||
267 | |||
268 | /* __________________ BBB RECORDING METHODS _________________ */ |
||
269 | /* The methods in the following section support the following categories of the BBB API: |
||
270 | -- getRecordings |
||
271 | -- publishRecordings |
||
272 | -- deleteRecordings |
||
273 | */ |
||
274 | |||
275 | /** |
||
276 | * @param $recordingsParams GetRecordingsParameters |
||
277 | * @return string |
||
278 | */ |
||
279 | public function getRecordingsUrl($recordingsParams) |
||
283 | |||
284 | /** |
||
285 | * @param $recordingParams |
||
286 | * @return GetRecordingsResponse |
||
287 | * @throws \RuntimeException |
||
288 | */ |
||
289 | public function getRecordings($recordingParams) |
||
295 | |||
296 | /** |
||
297 | * @param $recordingParams PublishRecordingsParameters |
||
298 | * @return string |
||
299 | */ |
||
300 | public function getPublishRecordingsUrl($recordingParams) |
||
304 | |||
305 | /** |
||
306 | * @param $recordingParams PublishRecordingsParameters |
||
307 | * @return PublishRecordingsResponse |
||
308 | * @throws \RuntimeException |
||
309 | */ |
||
310 | public function publishRecordings($recordingParams) |
||
316 | |||
317 | /** |
||
318 | * @param $recordingParams DeleteRecordingsParameters |
||
319 | * @return string |
||
320 | */ |
||
321 | public function getDeleteRecordingsUrl($recordingParams) |
||
325 | |||
326 | /** |
||
327 | * @param $recordingParams DeleteRecordingsParameters |
||
328 | * @return DeleteRecordingsResponse |
||
329 | * @throws \RuntimeException |
||
330 | */ |
||
331 | public function deleteRecordings($recordingParams) |
||
337 | |||
338 | /** |
||
339 | * @param $recordingParams UpdateRecordingsParameters |
||
340 | * @return string |
||
341 | */ |
||
342 | public function getUpdateRecordingsUrl($recordingParams) |
||
346 | |||
347 | /** |
||
348 | * @param $recordingParams UpdateRecordingsParameters |
||
349 | * @return UpdateRecordingsResponse |
||
350 | * @throws \RuntimeException |
||
351 | */ |
||
352 | public function updateRecordings($recordingParams) |
||
358 | |||
359 | /* ____________________ WEB HOOKS METHODS ___________________ */ |
||
360 | |||
361 | /** |
||
362 | * @param $hookCreateParams HooksCreateParameters |
||
363 | * @return string |
||
364 | */ |
||
365 | public function getHooksCreateUrl($hookCreateParams) |
||
369 | |||
370 | /** |
||
371 | * @param $hookCreateParams |
||
372 | * @return HooksCreateResponse |
||
373 | */ |
||
374 | public function hooksCreate($hookCreateParams) |
||
380 | |||
381 | /** |
||
382 | * @return string |
||
383 | */ |
||
384 | public function getHooksListUrl() |
||
388 | |||
389 | /** |
||
390 | * @return HooksListResponse |
||
391 | */ |
||
392 | public function hooksList() |
||
398 | |||
399 | /** |
||
400 | * @param $hooksDestroyParams HooksDestroyParameters |
||
401 | * @return string |
||
402 | */ |
||
403 | public function getHooksDestroyUrl($hooksDestroyParams) |
||
407 | |||
408 | /** |
||
409 | * @param $hooksDestroyParams |
||
410 | * @return HooksDestroyResponse |
||
411 | */ |
||
412 | public function hooksDestroy($hooksDestroyParams) |
||
418 | |||
419 | /* ____________________ SPECIAL METHODS ___________________ */ |
||
420 | /** |
||
421 | * @return string |
||
422 | */ |
||
423 | public function getJSessionId() |
||
427 | |||
428 | /** |
||
429 | * @param string $jSessionId |
||
430 | */ |
||
431 | public function setJSessionId($jSessionId) |
||
435 | |||
436 | /* ____________________ INTERNAL CLASS METHODS ___________________ */ |
||
437 | |||
438 | /** |
||
439 | * A private utility method used by other public methods to process XML responses. |
||
440 | * |
||
441 | * @param string $url |
||
442 | * @param string $payload |
||
443 | * @param string $contentType |
||
444 | * @return SimpleXMLElement |
||
445 | * @throws \RuntimeException |
||
446 | */ |
||
447 | private function processXmlResponse($url, $payload = '', $contentType = 'application/xml') |
||
494 | } |
||
495 |