Conditions | 2 |
Paths | 2 |
Total Lines | 61 |
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 |
||
109 | public function manage(FederatedEvent $event): void { |
||
110 | if ($this->configService->isLocalInstance($event->getOrigin())) { |
||
111 | return; |
||
112 | } |
||
113 | |||
114 | /** @var ShareWrapper $wrappedShare */ |
||
115 | $wrappedShare = $event->getData()->gObj('wrappedShare', ShareWrapper::class); |
||
116 | $mount = new Mount(); |
||
117 | $mount->fromShare($wrappedShare); |
||
118 | $mount->setMountId($this->token(15)); |
||
119 | |||
120 | $this->mountRequest->save($mount); |
||
121 | $this->eventService->federatedShareCreated($wrappedShare, $mount); |
||
122 | |||
123 | // $this->mountRequest->create($mount); |
||
124 | // $circle = $event->getDeprecatedCircle(); |
||
125 | // |
||
126 | // // if event is not local, we create a federated file to the right instance of Nextcloud, using the right token |
||
127 | // if (!$this->configService->isLocalInstance($event->getSource())) { |
||
128 | // try { |
||
129 | // $share = $this->getShareFromData($event->getData()); |
||
130 | // } catch (Exception $e) { |
||
131 | // return; |
||
132 | // } |
||
133 | // |
||
134 | // $data = $event->getData(); |
||
135 | // $token = $data->g('gs_federated'); |
||
136 | // $filename = $data->g('gs_filename'); |
||
137 | // |
||
138 | // $gsShare = new GSShare($share->getSharedWith(), $token); |
||
139 | // $gsShare->setOwner($share->getShareOwner()); |
||
140 | // $gsShare->setInstance($event->getSource()); |
||
141 | // $gsShare->setParent(-1); |
||
142 | // $gsShare->setMountPoint($filename); |
||
143 | // |
||
144 | // $this->gsSharesRequest->create($gsShare); |
||
145 | // } else { |
||
146 | // // if the event is local, we send mail to mail-as-members |
||
147 | // $members = $this->membersRequest->forceGetMembers( |
||
148 | // $circle->getUniqueId(), DeprecatedMember::LEVEL_MEMBER, DeprecatedMember::TYPE_MAIL, true |
||
149 | // ); |
||
150 | // |
||
151 | // foreach ($members as $member) { |
||
152 | // $this->sendShareToContact($event, $circle, $member->getMemberId(), [$member->getUserId()]); |
||
153 | // } |
||
154 | // } |
||
155 | // |
||
156 | // // we also fill the event's result for further things, like contact-as-members |
||
157 | // $members = $this->membersRequest->forceGetMembers( |
||
158 | // $circle->getUniqueId(), DeprecatedMember::LEVEL_MEMBER, DeprecatedMember::TYPE_CONTACT, true |
||
159 | // ); |
||
160 | // |
||
161 | // $accounts = []; |
||
162 | // foreach ($members as $member) { |
||
163 | // if ($member->getInstance() === '') { |
||
164 | // $accounts[] = $this->miscService->getInfosFromContact($member); |
||
165 | // } |
||
166 | // } |
||
167 | // |
||
168 | // $event->setResult(new SimpleDataStore(['contacts' => $accounts])); |
||
169 | } |
||
170 | |||
200 |