Complex classes like MembersRequest 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 MembersRequest, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
38 | class MembersRequest extends MembersRequestBuilder { |
||
39 | |||
40 | |||
41 | use TStringTools; |
||
42 | |||
43 | |||
44 | /** |
||
45 | * Returns information about a member. |
||
46 | * |
||
47 | * WARNING: This function does not filters data regarding the current user/viewer. |
||
48 | * In case of interaction with users, Please use MembersService->getMember() instead. |
||
49 | * |
||
50 | * @param string $circleUniqueId |
||
51 | * @param string $userId |
||
52 | * @param $type |
||
53 | * |
||
54 | * @return Member |
||
55 | * @throws MemberDoesNotExistException |
||
56 | */ |
||
57 | public function forceGetMember($circleUniqueId, $userId, $type) { |
||
74 | |||
75 | |||
76 | /** |
||
77 | * @param string $memberId |
||
78 | * |
||
79 | * @return Member |
||
80 | * @throws MemberDoesNotExistException |
||
81 | */ |
||
82 | public function forceGetMemberById(string $memberId): Member { |
||
97 | |||
98 | |||
99 | /** |
||
100 | * Returns members list of a circle, based on their level. |
||
101 | * |
||
102 | * WARNING: This function does not filters data regarding the current user/viewer. |
||
103 | * In case of interaction with users, Please use getMembers() instead. |
||
104 | * |
||
105 | * @param string $circleUniqueId |
||
106 | * @param int $level |
||
107 | * @param bool $incGroup |
||
108 | * |
||
109 | * @return Member[] |
||
110 | */ |
||
111 | public function forceGetMembers($circleUniqueId, $level = Member::LEVEL_MEMBER, $incGroup = false) { |
||
132 | |||
133 | |||
134 | /** |
||
135 | * Returns all members. |
||
136 | * |
||
137 | * WARNING: This function does not filters data regarding the current user/viewer. |
||
138 | * In case of interaction with users, Please use getMembers() instead. |
||
139 | * |
||
140 | * |
||
141 | * @return Member[] |
||
142 | */ |
||
143 | public function forceGetAllMembers() { |
||
156 | |||
157 | |||
158 | /** |
||
159 | * Returns members generated from Contacts that are not 'checked' (as not sent existing shares). |
||
160 | * |
||
161 | * |
||
162 | * @return Member[] |
||
163 | */ |
||
164 | public function forceGetAllRecentContactEdit() { |
||
183 | |||
184 | |||
185 | /** |
||
186 | * @param Member $member |
||
187 | * @param bool $check |
||
188 | */ |
||
189 | public function checkMember(Member $member, bool $check) { |
||
195 | |||
196 | |||
197 | /** |
||
198 | * @param string $circleUniqueId |
||
199 | * @param Member $viewer |
||
200 | * @param bool $force |
||
201 | * |
||
202 | * @return Member[] |
||
203 | */ |
||
204 | public function getMembers($circleUniqueId, ?Member $viewer, bool $force = false) { |
||
226 | |||
227 | |||
228 | /** |
||
229 | * forceGetGroup(); |
||
230 | * |
||
231 | * returns group information as a member within a Circle. |
||
232 | * |
||
233 | * WARNING: This function does not filters data regarding the current user/viewer. |
||
234 | * In case of interaction with users, Please use getGroup() instead. |
||
235 | * |
||
236 | * @param string $circleUniqueId |
||
237 | * @param string $groupId |
||
238 | * |
||
239 | * @return Member |
||
240 | * @throws MemberDoesNotExistException |
||
241 | */ |
||
242 | public function forceGetGroup($circleUniqueId, $groupId) { |
||
259 | |||
260 | |||
261 | /** |
||
262 | * includeGroupMembers(); |
||
263 | * |
||
264 | * This function will get members of a circle throw NCGroups and fill the result an existing |
||
265 | * Members List. In case of duplicate, higher level will be kept. |
||
266 | * |
||
267 | * @param Member[] $members |
||
268 | * @param string $circleUniqueId |
||
269 | * @param int $level |
||
270 | */ |
||
271 | private function includeGroupMembers(array &$members, $circleUniqueId, $level) { |
||
276 | |||
277 | |||
278 | /** |
||
279 | * avoidDuplicateMembers(); |
||
280 | * |
||
281 | * Use this function to add members to the list (1st argument), keeping the higher level in case |
||
282 | * of duplicate |
||
283 | * |
||
284 | * @param Member[] $members |
||
285 | * @param Member[] $groupMembers |
||
286 | */ |
||
287 | public function avoidDuplicateMembers(array &$members, array $groupMembers) { |
||
297 | |||
298 | |||
299 | /** |
||
300 | * returns the index of a specific UserID in a Members List |
||
301 | * |
||
302 | * @param array $members |
||
303 | * @param $userId |
||
304 | * |
||
305 | * @return int |
||
306 | */ |
||
307 | private function indexOfMember(array $members, $userId) { |
||
317 | |||
318 | |||
319 | /** |
||
320 | * Check if a fresh member can be generated (by addMember/joinCircle) |
||
321 | * |
||
322 | * @param string $circleUniqueId |
||
323 | * @param string $name |
||
324 | * @param $type |
||
325 | * |
||
326 | * @return Member |
||
327 | * @throws MemberAlreadyExistsException |
||
328 | * @throws \Exception |
||
329 | */ |
||
330 | public function getFreshNewMember($circleUniqueId, $name, $type) { |
||
349 | |||
350 | |||
351 | /** |
||
352 | * Returns members list of all Group Members of a Circle. The Level of the linked group will be |
||
353 | * assigned to each entry |
||
354 | * |
||
355 | * NOTE: Can contains duplicate. |
||
356 | * |
||
357 | * WARNING: This function does not filters data regarding the current user/viewer. |
||
358 | * Do not use in case of direct interaction with users. |
||
359 | * |
||
360 | * @param string $circleUniqueId |
||
361 | * @param int $level |
||
362 | * |
||
363 | * @return Member[] |
||
364 | */ |
||
365 | public function forceGetGroupMembers($circleUniqueId, $level = Member::LEVEL_MEMBER) { |
||
381 | |||
382 | |||
383 | /** |
||
384 | * returns all users from a Group as a list of Members. |
||
385 | * |
||
386 | * @param Member $group |
||
387 | * |
||
388 | * @return Member[] |
||
389 | */ |
||
390 | public function getGroupMemberMembers(Member $group) { |
||
409 | |||
410 | |||
411 | /** |
||
412 | * return the higher level group linked to a circle, that include the userId. |
||
413 | * |
||
414 | * WARNING: This function does not filters data regarding the current user/viewer. |
||
415 | * In case of direct interaction with users, Please don't use this. |
||
416 | * |
||
417 | * @param string $circleUniqueId |
||
418 | * @param string $userId |
||
419 | * |
||
420 | * @return Member |
||
421 | */ |
||
422 | public function forceGetHigherLevelGroupFromUser($circleUniqueId, $userId) { |
||
442 | |||
443 | |||
444 | /** |
||
445 | * Insert Member into database. |
||
446 | * |
||
447 | * @param Member $member |
||
448 | * |
||
449 | * @throws MemberAlreadyExistsException |
||
450 | */ |
||
451 | public function createMember(Member $member) { |
||
475 | |||
476 | |||
477 | /** |
||
478 | * @param string $circleUniqueId |
||
479 | * @param Member $viewer |
||
480 | * |
||
481 | * @return Member[] |
||
482 | * @throws MemberDoesNotExistException |
||
483 | */ |
||
484 | public function getGroupsFromCircle($circleUniqueId, Member $viewer) { |
||
506 | |||
507 | |||
508 | /** |
||
509 | * Insert Member into database. |
||
510 | * |
||
511 | * @param Member $member |
||
512 | * |
||
513 | * @throws MemberAlreadyExistsException |
||
514 | */ |
||
515 | public function insertGroup(Member $member) { |
||
530 | |||
531 | |||
532 | /** |
||
533 | * update database entry for a specific Member. |
||
534 | * |
||
535 | * @param Member $member |
||
536 | */ |
||
537 | public function updateMember(Member $member) { |
||
544 | |||
545 | /** |
||
546 | * update database entry for a specific Member. |
||
547 | * |
||
548 | * @param Member $member |
||
549 | */ |
||
550 | public function updateContactMeta(Member $member) { |
||
556 | |||
557 | |||
558 | /** |
||
559 | * removeAllFromCircle(); |
||
560 | * |
||
561 | * Remove All members from a Circle. Used when deleting a Circle. |
||
562 | * |
||
563 | * @param string $uniqueCircleId |
||
564 | */ |
||
565 | public function removeAllFromCircle($uniqueCircleId) { |
||
572 | |||
573 | |||
574 | /** |
||
575 | * removeAllMembershipsFromUser(); |
||
576 | * |
||
577 | * remove All membership from a User. Used when removing a User from the Cloud. |
||
578 | * |
||
579 | * @param string $userId |
||
580 | */ |
||
581 | public function removeAllMembershipsFromUser($userId) { |
||
599 | |||
600 | |||
601 | /** |
||
602 | * remove member, identified by its id, type and circleId |
||
603 | * |
||
604 | * @param Member $member |
||
605 | */ |
||
606 | public function removeMember(Member $member) { |
||
617 | |||
618 | /** |
||
619 | * update database entry for a specific Group. |
||
620 | * |
||
621 | * @param Member $member |
||
622 | * |
||
623 | * @return bool |
||
624 | */ |
||
625 | public function updateGroup(Member $member) { |
||
632 | |||
633 | |||
634 | public function unlinkAllFromGroup($groupId) { |
||
638 | |||
639 | |||
640 | public function unlinkFromGroup($circleId, $groupId) { |
||
646 | |||
647 | |||
648 | /** |
||
649 | * @param string $contactId |
||
650 | * |
||
651 | * @return Member[] |
||
652 | */ |
||
653 | public function getMembersByContactId(string $contactId = ''): array { |
||
672 | |||
673 | |||
674 | /** |
||
675 | * @param string $circleId |
||
676 | * @param string $contactId |
||
677 | * @param string $userId |
||
678 | * @param int $type |
||
679 | * |
||
680 | * @return Member |
||
681 | * @throws MemberDoesNotExistException |
||
682 | */ |
||
683 | public function getContactMember(string $circleId, string $contactId): Member { |
||
698 | |||
699 | |||
700 | /** |
||
701 | * @param string $contactId |
||
702 | * |
||
703 | * @return Member[] |
||
704 | */ |
||
705 | public function getLocalContactMembers(string $contactId): array { |
||
719 | |||
720 | |||
721 | /** |
||
722 | * @param string $contactId |
||
723 | * @param int $type |
||
724 | */ |
||
725 | public function removeMembersByContactId(string $contactId, int $type = 0) { |
||
739 | |||
740 | |||
741 | } |
||
742 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.