Complex classes like Client 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 Client, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
13 | class Client |
||
14 | { |
||
15 | /** |
||
16 | * Microsoft Exchange 2007 |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | const VERSION_2007 = 'Exchange2007'; |
||
21 | |||
22 | /** |
||
23 | * Microsoft Exchange 2007 SP1 |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | const VERSION_2007_SP1 = 'Exchange2007_SP1'; |
||
28 | |||
29 | /** |
||
30 | * Microsoft Exchange 2007 SP2 |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | const VERSION_2007_SP2 = 'Exchange2007_SP2'; |
||
35 | |||
36 | /** |
||
37 | * Microsoft Exchange 2007 SP3 |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | const VERSION_2007_SP3 = 'Exchange2007_SP3'; |
||
42 | |||
43 | /** |
||
44 | * Microsoft Exchange 2010 |
||
45 | * |
||
46 | * @var string |
||
47 | */ |
||
48 | const VERSION_2010 = 'Exchange2010'; |
||
49 | |||
50 | /** |
||
51 | * Microsoft Exchange 2010 SP1 |
||
52 | * |
||
53 | * @var string |
||
54 | */ |
||
55 | const VERSION_2010_SP1 = 'Exchange2010_SP1'; |
||
56 | |||
57 | /** |
||
58 | * Microsoft Exchange 2010 SP2 |
||
59 | * |
||
60 | * @var string |
||
61 | */ |
||
62 | const VERSION_2010_SP2 = 'Exchange2010_SP2'; |
||
63 | |||
64 | /** |
||
65 | * Microsoft Exchange 2013. |
||
66 | * |
||
67 | * @var string |
||
68 | */ |
||
69 | const VERSION_2013 = 'Exchange2013'; |
||
70 | |||
71 | /** |
||
72 | * Microsoft Exchange 2013 SP1. |
||
73 | * |
||
74 | * @var string |
||
75 | */ |
||
76 | const VERSION_2013_SP1 = 'Exchange2013_SP1'; |
||
77 | |||
78 | /** |
||
79 | * Microsoft Exchange 2016. |
||
80 | * |
||
81 | * @var string |
||
82 | */ |
||
83 | const VERSION_2016 = 'Exchange2016'; |
||
84 | |||
85 | /** |
||
86 | * Password to use when connecting to the Exchange server. |
||
87 | * |
||
88 | * @var string |
||
89 | */ |
||
90 | protected $password; |
||
91 | |||
92 | /** |
||
93 | * Location of the Exchange server. |
||
94 | * |
||
95 | * @var string |
||
96 | */ |
||
97 | protected $server; |
||
98 | |||
99 | /** |
||
100 | * SOAP client used to make the request |
||
101 | * |
||
102 | * @var \jamesiarmes\PhpEws\SoapClient |
||
103 | */ |
||
104 | protected $soap; |
||
105 | |||
106 | /** |
||
107 | * Username to use when connecting to the Exchange server. |
||
108 | * |
||
109 | * @var string |
||
110 | */ |
||
111 | protected $username; |
||
112 | |||
113 | /** |
||
114 | * Exchange impersonation |
||
115 | * |
||
116 | * @var \jamesiarmes\PhpEws\Type\ExchangeImpersonationType |
||
117 | */ |
||
118 | protected $impersonation; |
||
119 | |||
120 | /** |
||
121 | * Miscrosoft Exchange version that we are going to connect to |
||
122 | * |
||
123 | * @var string |
||
124 | * |
||
125 | * @see Client::VERSION_2007 |
||
126 | * @see Client::VERSION_2007_SP1 |
||
127 | * @see Client::VERSION_2007_SP2 |
||
128 | * @see Client::VERSION_2007_SP3 |
||
129 | * @see Client::VERSION_2010 |
||
130 | * @see Client::VERSION_2010_SP1 |
||
131 | * @see Client::VERSION_2010_SP2 |
||
132 | */ |
||
133 | protected $version; |
||
134 | |||
135 | /** |
||
136 | * Constructor for the ExchangeWebServices class |
||
137 | * |
||
138 | * @param string $server |
||
139 | * @param string $username |
||
140 | * @param string $password |
||
141 | * @param string $version One of the Client::VERSION_* constants. |
||
142 | */ |
||
143 | public function __construct( |
||
155 | |||
156 | /** |
||
157 | * Returns the SOAP Client that may be used to make calls against the server |
||
158 | * |
||
159 | * @return \jamesiarmes\PhpEws\SoapClient |
||
160 | */ |
||
161 | public function getClient() |
||
165 | |||
166 | /** |
||
167 | * Sets the impersonation property |
||
168 | * |
||
169 | * @param \jamesiarmes\PhpEws\Type\ExchangeImpersonationType $impersonation |
||
170 | */ |
||
171 | public function setImpersonation($impersonation) |
||
177 | |||
178 | /** |
||
179 | * Sets the password property |
||
180 | * |
||
181 | * @param string $password |
||
182 | */ |
||
183 | public function setPassword($password) |
||
189 | |||
190 | /** |
||
191 | * Sets the server property |
||
192 | * |
||
193 | * @param string $server |
||
194 | */ |
||
195 | public function setServer($server) |
||
201 | |||
202 | /** |
||
203 | * Sets the user name property |
||
204 | * |
||
205 | * @param string $username |
||
206 | */ |
||
207 | public function setUsername($username) |
||
213 | |||
214 | /** |
||
215 | * Sets the version property |
||
216 | * |
||
217 | * @param string $version |
||
218 | */ |
||
219 | public function setVersion($version) |
||
225 | |||
226 | /** |
||
227 | * Function Description |
||
228 | * |
||
229 | * @param \jamesiarmes\PhpEws\Request\AddDelegateType $request |
||
230 | * @return \jamesiarmes\PhpEws\Response\AddDelegateResponseMessageType |
||
231 | */ |
||
232 | public function AddDelegate($request) |
||
239 | |||
240 | /** |
||
241 | * Adds a distribution group to the instant messaging (IM) list in the |
||
242 | * Unified Contact Store. |
||
243 | * |
||
244 | * @param \jamesiarmes\PhpEws\Request\AddDistributionGroupToImListType $request |
||
245 | * @return \jamesiarmes\PhpEws\Response\AddDistributionGroupToImListResponseMessageType |
||
246 | * |
||
247 | * @since Exchange 2013 |
||
248 | */ |
||
249 | public function AddDistributionGroupToImList($request) |
||
256 | |||
257 | /** |
||
258 | * Adds an existing instant messaging (IM) contact to a group. |
||
259 | * |
||
260 | * @param \jamesiarmes\PhpEws\Request\AddImContactToGroup $request |
||
261 | * @return \jamesiarmes\PhpEws\Response\AddImContactToGroupResponseMessageType |
||
262 | * |
||
263 | * @since Exchange 2013 |
||
264 | */ |
||
265 | public function AddImContactToGroup($request) |
||
272 | |||
273 | /** |
||
274 | * Adds a new instant messaging (IM) group to a mailbox. |
||
275 | * |
||
276 | * @param \jamesiarmes\PhpEws\Request\AddImGroupType $request |
||
277 | * @return \jamesiarmes\PhpEws\Response\AddImGroupResponseMessageType |
||
278 | * |
||
279 | * @since Exchange 2013 |
||
280 | */ |
||
281 | public function AddImGroup($request) |
||
288 | |||
289 | /** |
||
290 | * Adds a new contact to an instant messaging (IM) group. |
||
291 | * |
||
292 | * @since Exchange 2013 |
||
293 | * |
||
294 | * @param \jamesiarmes\PhpEws\Request\AddNewImContactToGroup $request |
||
295 | * @return \jamesiarmes\PhpEws\Response\AddNewImContactToGroupResponseMessageType |
||
296 | */ |
||
297 | public function AddNewImContactToGroup($request) |
||
304 | |||
305 | /** |
||
306 | * Function Description |
||
307 | * |
||
308 | * @param \jamesiarmes\PhpEws\Request\ConvertIdType $request |
||
309 | * @return \jamesiarmes\PhpEws\Response\ConvertIdResponseType |
||
310 | */ |
||
311 | public function ConvertId($request) |
||
318 | |||
319 | /** |
||
320 | * Function Description |
||
321 | * |
||
322 | * @param \jamesiarmes\PhpEws\Request\CopyFolderType $request |
||
323 | * @return \jamesiarmes\PhpEws\Response\CopyFolderResponseType |
||
324 | */ |
||
325 | public function CopyFolder($request) |
||
332 | |||
333 | /** |
||
334 | * Function Description |
||
335 | * |
||
336 | * @param \jamesiarmes\PhpEws\Request\CopyItemType $request |
||
337 | * @return \jamesiarmes\PhpEws\Response\CopyItemResponseType |
||
338 | */ |
||
339 | public function CopyItem($request) |
||
346 | |||
347 | /** |
||
348 | * Function Description |
||
349 | * |
||
350 | * @param \jamesiarmes\PhpEws\Request\CreateAttachmentType $request |
||
351 | * @return \jamesiarmes\PhpEws\Response\CreateAttachmentResponseType |
||
352 | */ |
||
353 | public function CreateAttachment($request) |
||
360 | |||
361 | /** |
||
362 | * Function Description |
||
363 | * |
||
364 | * @param \jamesiarmes\PhpEws\Request\CreateFolderType $request |
||
365 | * @return \jamesiarmes\PhpEws\Response\CreateFolderResponseType |
||
366 | */ |
||
367 | public function CreateFolder($request) |
||
374 | |||
375 | /** |
||
376 | * Function Description |
||
377 | * |
||
378 | * @param \jamesiarmes\PhpEws\Request\CreateItemType $request |
||
379 | * @return \jamesiarmes\PhpEws\Response\CreateItemResponseType |
||
380 | */ |
||
381 | public function CreateItem($request) |
||
388 | |||
389 | /** |
||
390 | * Function Description |
||
391 | * |
||
392 | * @param \jamesiarmes\PhpEws\Request\CreateManagedFolderRequestType $request |
||
393 | * @return \jamesiarmes\PhpEws\Response\CreateManagedFolderResponseType |
||
394 | */ |
||
395 | public function CreateManagedFolder($request) |
||
402 | |||
403 | /** |
||
404 | * Function Description |
||
405 | * |
||
406 | * @param \jamesiarmes\PhpEws\Request\DeleteAttachmentType $request |
||
407 | * @return \jamesiarmes\PhpEws\Response\DeleteAttachmentResponseType |
||
408 | */ |
||
409 | public function DeleteAttachment($request) |
||
416 | |||
417 | /** |
||
418 | * Function Description |
||
419 | * |
||
420 | * @param \jamesiarmes\PhpEws\Request\DeleteFolderType $request |
||
421 | * @return \jamesiarmes\PhpEws\Response\DeleteFolderResponseType |
||
422 | */ |
||
423 | public function DeleteFolder($request) |
||
430 | |||
431 | /** |
||
432 | * Function Description |
||
433 | * |
||
434 | * @param \jamesiarmes\PhpEws\Request\DeleteItemType $request |
||
435 | * @return \jamesiarmes\PhpEws\Response\DeleteItemResponseType |
||
436 | */ |
||
437 | public function DeleteItem($request) |
||
444 | |||
445 | /** |
||
446 | * Function Description |
||
447 | * |
||
448 | * @param \jamesiarmes\PhpEws\Request\ExpandDLType $request |
||
449 | * @return \jamesiarmes\PhpEws\Response\ExpandDLResponseType |
||
450 | */ |
||
451 | public function ExpandDL($request) |
||
458 | |||
459 | /** |
||
460 | * Function Description |
||
461 | * |
||
462 | * @param \jamesiarmes\PhpEws\Request\FindFolderType $request |
||
463 | * @return \jamesiarmes\PhpEws\Response\FindFolderResponseType |
||
464 | */ |
||
465 | public function FindFolder($request) |
||
472 | |||
473 | /** |
||
474 | * Function Description |
||
475 | * |
||
476 | * @param \jamesiarmes\PhpEws\Request\FindItemType $request |
||
477 | * @return \jamesiarmes\PhpEws\Response\FindItemResponseType |
||
478 | */ |
||
479 | public function FindItem($request) |
||
486 | |||
487 | /** |
||
488 | * Function Description |
||
489 | * |
||
490 | * @param \jamesiarmes\PhpEws\Request\GetAttachmentType $request |
||
491 | * @return \jamesiarmes\PhpEws\Response\GetAttachmentResponseType |
||
492 | */ |
||
493 | public function GetAttachment($request) |
||
500 | |||
501 | /** |
||
502 | * Function Description |
||
503 | * |
||
504 | * @param \jamesiarmes\PhpEws\Request\GetDelegateType $request |
||
505 | * @return \jamesiarmes\PhpEws\Response\GetDelegateResponseMessageType |
||
506 | */ |
||
507 | public function GetDelegate($request) |
||
514 | |||
515 | /** |
||
516 | * Function Description |
||
517 | * |
||
518 | * @param \jamesiarmes\PhpEws\Request\GetEventsType $request |
||
519 | * @return \jamesiarmes\PhpEws\Response\GetEventsResponseType |
||
520 | */ |
||
521 | public function GetEvents($request) |
||
528 | |||
529 | /** |
||
530 | * Function Description |
||
531 | * |
||
532 | * @param \jamesiarmes\PhpEws\Request\GetFolderType $request |
||
533 | * @return \jamesiarmes\PhpEws\Response\GetFolderResponseType |
||
534 | */ |
||
535 | public function GetFolder($request) |
||
542 | |||
543 | /** |
||
544 | * Function Description |
||
545 | * |
||
546 | * @param \jamesiarmes\PhpEws\Request\GetItemType $request |
||
547 | * @return \jamesiarmes\PhpEws\Response\GetItemResponseType |
||
548 | */ |
||
549 | public function GetItem($request) |
||
556 | |||
557 | /** |
||
558 | * Retrieve the timezones supported by the server. |
||
559 | * |
||
560 | * @since Exchange 2010 |
||
561 | * |
||
562 | * @param \jamesiarmes\PhpEws\Request\GetServerTimeZonesType $request |
||
563 | * @return \jamesiarmes\PhpEws\Response\GetServerTimeZonesResponseType |
||
564 | */ |
||
565 | public function GetServerTimeZones($request) |
||
572 | |||
573 | /** |
||
574 | * Function Description |
||
575 | * |
||
576 | * @param \jamesiarmes\PhpEws\Request\GetUserAvailabilityRequestType $request |
||
577 | * @return \jamesiarmes\PhpEws\Response\GetUserAvailabilityResponseType |
||
578 | */ |
||
579 | public function GetUserAvailability($request) |
||
586 | |||
587 | /** |
||
588 | * Function Description |
||
589 | * |
||
590 | * @param \jamesiarmes\PhpEws\Request\GetUserOofSettingsRequest $request |
||
591 | * @return \jamesiarmes\PhpEws\Response\GetUserOofSettingsResponse |
||
592 | */ |
||
593 | public function GetUserOofSettings($request) |
||
600 | |||
601 | /** |
||
602 | * Function Description |
||
603 | * |
||
604 | * @param \jamesiarmes\PhpEws\Request\MoveFolderType $request |
||
605 | * @return \jamesiarmes\PhpEws\Response\MoveFolderResponseType |
||
606 | */ |
||
607 | public function MoveFolder($request) |
||
614 | |||
615 | /** |
||
616 | * Function Description |
||
617 | * |
||
618 | * @param \jamesiarmes\PhpEws\Request\MoveItemType $request |
||
619 | * @return \jamesiarmes\PhpEws\Response\MoveItemResponseType |
||
620 | */ |
||
621 | public function MoveItem($request) |
||
628 | |||
629 | /** |
||
630 | * Function Description |
||
631 | * |
||
632 | * @param \jamesiarmes\PhpEws\Request\RemoveDelegateType $request |
||
633 | * @return \jamesiarmes\PhpEws\Response\RemoveDelegateResponseMessageType |
||
634 | */ |
||
635 | public function RemoveDelegate($request) |
||
642 | |||
643 | /** |
||
644 | * Function Description |
||
645 | * |
||
646 | * @param \jamesiarmes\PhpEws\Request\ResolveNamesType $request |
||
647 | * @return \jamesiarmes\PhpEws\Response\ResolveNamesResponseType |
||
648 | */ |
||
649 | public function ResolveNames($request) |
||
656 | |||
657 | /** |
||
658 | * Function Description |
||
659 | * |
||
660 | * @param \jamesiarmes\PhpEws\Request\SendItemType $request |
||
661 | * @return \jamesiarmes\PhpEws\Response\SendItemResponseType |
||
662 | */ |
||
663 | public function SendItem($request) |
||
670 | |||
671 | /** |
||
672 | * Function Description |
||
673 | * |
||
674 | * @param \jamesiarmes\PhpEws\Request\SetUserOofSettingsRequest $request |
||
675 | * @return \jamesiarmes\PhpEws\Response\SetUserOofSettingsResponse |
||
676 | */ |
||
677 | public function SetUserOofSettings($request) |
||
684 | |||
685 | /** |
||
686 | * Function Description |
||
687 | * |
||
688 | * @param \jamesiarmes\PhpEws\Request\SubscribeType $request |
||
689 | * @return \jamesiarmes\PhpEws\Response\SubscribeResponseType |
||
690 | */ |
||
691 | public function Subscribe($request) |
||
698 | |||
699 | /** |
||
700 | * Function Description |
||
701 | * |
||
702 | * @param \jamesiarmes\PhpEws\Request\SyncFolderHierarchyType $request |
||
703 | * @return \jamesiarmes\PhpEws\Response\SyncFolderHierarchyResponseType |
||
704 | */ |
||
705 | public function SyncFolderHierarchy($request) |
||
712 | |||
713 | /** |
||
714 | * Function Description |
||
715 | * |
||
716 | * @param \jamesiarmes\PhpEws\Request\SyncFolderItemsType $request |
||
717 | * @return \jamesiarmes\PhpEws\Response\SyncFolderItemsResponseType |
||
718 | */ |
||
719 | public function SyncFolderItems($request) |
||
726 | |||
727 | /** |
||
728 | * Function Description |
||
729 | * |
||
730 | * @param \jamesiarmes\PhpEws\Request\UnsubscribeType $request |
||
731 | * @return \jamesiarmes\PhpEws\Response\UnsubscribeResponseType |
||
732 | */ |
||
733 | public function Unsubscribe($request) |
||
740 | |||
741 | /** |
||
742 | * Function Description |
||
743 | * |
||
744 | * @param \jamesiarmes\PhpEws\Request\UpdateDelegateType $request |
||
745 | * @return \jamesiarmes\PhpEws\Response\UpdateDelegateResponseMessageType |
||
746 | */ |
||
747 | public function UpdateDelegate($request) |
||
754 | |||
755 | /** |
||
756 | * Function Description |
||
757 | * |
||
758 | * @param \jamesiarmes\PhpEws\Request\UpdateFolderType $request |
||
759 | * @return \jamesiarmes\PhpEws\Response\UpdateFolderResponseType |
||
760 | */ |
||
761 | public function UpdateFolder($request) |
||
768 | |||
769 | /** |
||
770 | * Function Description |
||
771 | * |
||
772 | * @param \jamesiarmes\PhpEws\Request\UpdateItemType $request |
||
773 | * @return \jamesiarmes\PhpEws\Response\UpdateItemResponseType |
||
774 | */ |
||
775 | public function UpdateItem($request) |
||
782 | |||
783 | /** |
||
784 | * Initializes the SoapClient object to make a request |
||
785 | * |
||
786 | * @return \jamesiarmes\PhpEws\SoapClient |
||
787 | * |
||
788 | * TODO: Build a class map that we can pass to the client. |
||
789 | */ |
||
790 | protected function initializeSoapClient() |
||
805 | |||
806 | /** |
||
807 | * Process a response to verify that it succeeded and take the appropriate |
||
808 | * action |
||
809 | * |
||
810 | * @throws \Exception |
||
811 | * |
||
812 | * @param \stdClass $response |
||
813 | * @return \stdClass |
||
814 | */ |
||
815 | protected function processResponse($response) |
||
828 | } |
||
829 |