| Conditions | 10 |
| Paths | 261 |
| Total Lines | 47 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php declare(strict_types=1); |
||
| 87 | private function syncCircle(Circle $circle, string $source): void { |
||
| 88 | try { |
||
| 89 | $knownCircle = $this->circlesRequest->forceGetCircle($circle->getUniqueId()); |
||
| 90 | |||
| 91 | if (!$this->compareCircles($knownCircle, $circle)) { |
||
| 92 | try { |
||
| 93 | $this->circlesRequest->updateCircle($circle); |
||
| 94 | } catch (CircleAlreadyExistsException $e) { |
||
|
|
|||
| 95 | } |
||
| 96 | } |
||
| 97 | } catch (CircleDoesNotExistException $e) { |
||
| 98 | try { |
||
| 99 | $this->circlesRequest->createCircle($circle); |
||
| 100 | } catch (CircleAlreadyExistsException $e) { |
||
| 101 | } |
||
| 102 | } |
||
| 103 | |||
| 104 | foreach ($circle->getMembers() as $member) { |
||
| 105 | if ($member->getInstance() === '') { |
||
| 106 | $member->setInstance($source); |
||
| 107 | } |
||
| 108 | |||
| 109 | try { |
||
| 110 | $knownMember = $this->membersRequest->forceGetMember( |
||
| 111 | $circle->getUniqueId(), $member->getUserId(), $member->getType(), $member->getInstance() |
||
| 112 | ); |
||
| 113 | |||
| 114 | if ($this->compareMembers($knownMember, $member)) { |
||
| 115 | continue; |
||
| 116 | } |
||
| 117 | |||
| 118 | $this->miscService->log( |
||
| 119 | 'updating member :' . json_encode($member) . ' from ' . json_encode($knownMember), 2 |
||
| 120 | ); |
||
| 121 | $this->membersRequest->updateMember($member); |
||
| 122 | } catch (MemberDoesNotExistException $e) { |
||
| 123 | try { |
||
| 124 | $this->miscService->log( |
||
| 125 | 'creating member :' . json_encode($member), 2 |
||
| 126 | ); |
||
| 127 | $this->membersRequest->createMember($member); |
||
| 128 | } catch (MemberAlreadyExistsException $e) { |
||
| 129 | } |
||
| 130 | } |
||
| 131 | } |
||
| 132 | |||
| 133 | } |
||
| 134 | |||
| 173 |