Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like FilesHooks 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 FilesHooks, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
50 | class FilesHooks { |
||
51 | const USER_BATCH_SIZE = 50; |
||
52 | |||
53 | /** @var \OCP\Activity\IManager */ |
||
54 | protected $manager; |
||
55 | |||
56 | /** @var \OCA\Activity\Data */ |
||
57 | protected $activityData; |
||
58 | |||
59 | /** @var \OCA\Activity\UserSettings */ |
||
60 | protected $userSettings; |
||
61 | |||
62 | /** @var \OCP\IGroupManager */ |
||
63 | protected $groupManager; |
||
64 | |||
65 | /** @var \OCP\IDBConnection */ |
||
66 | protected $connection; |
||
67 | |||
68 | /** @var \OC\Files\View */ |
||
69 | protected $view; |
||
70 | |||
71 | /** @var IRootFolder */ |
||
72 | protected $rootFolder; |
||
73 | |||
74 | /** @var IShareHelper */ |
||
75 | protected $shareHelper; |
||
76 | |||
77 | /** @var IURLGenerator */ |
||
78 | protected $urlGenerator; |
||
79 | |||
80 | /** @var ILogger */ |
||
81 | protected $logger; |
||
82 | |||
83 | /** @var CurrentUser */ |
||
84 | protected $currentUser; |
||
85 | |||
86 | /** @var string|bool */ |
||
87 | protected $moveCase = false; |
||
88 | /** @var array */ |
||
89 | protected $oldAccessList; |
||
90 | /** @var string */ |
||
91 | protected $oldParentPath; |
||
92 | /** @var string */ |
||
93 | protected $oldParentOwner; |
||
94 | /** @var string */ |
||
95 | protected $oldParentId; |
||
96 | |||
97 | /** |
||
98 | * Constructor |
||
99 | * |
||
100 | * @param IManager $manager |
||
101 | * @param Data $activityData |
||
102 | * @param UserSettings $userSettings |
||
103 | * @param IGroupManager $groupManager |
||
104 | * @param View $view |
||
105 | * @param IRootFolder $rootFolder |
||
106 | * @param IShareHelper $shareHelper |
||
107 | * @param IDBConnection $connection |
||
108 | * @param IURLGenerator $urlGenerator |
||
109 | * @param ILogger $logger |
||
110 | * @param CurrentUser $currentUser |
||
111 | */ |
||
112 | 49 | public function __construct(IManager $manager, |
|
135 | |||
136 | /** |
||
137 | * Store the create hook events |
||
138 | * @param string $path Path of the file that has been created |
||
139 | */ |
||
140 | 4 | public function fileCreate($path) { |
|
141 | 4 | if ($path === '/' || $path === '' || $path === null) { |
|
142 | 2 | return; |
|
143 | } |
||
144 | |||
145 | 2 | if ($this->currentUser->getUserIdentifier() !== '') { |
|
146 | 1 | $this->addNotificationsForFileAction($path, Files::TYPE_SHARE_CREATED, 'created_self', 'created_by'); |
|
147 | } else { |
||
148 | 1 | $this->addNotificationsForFileAction($path, Files::TYPE_SHARE_CREATED, '', 'created_public'); |
|
149 | } |
||
150 | 2 | } |
|
151 | |||
152 | /** |
||
153 | * Store the update hook events |
||
154 | * @param string $path Path of the file that has been modified |
||
155 | */ |
||
156 | 1 | public function fileUpdate($path) { |
|
159 | |||
160 | /** |
||
161 | * Store the delete hook events |
||
162 | * @param string $path Path of the file that has been deleted |
||
163 | */ |
||
164 | 1 | public function fileDelete($path) { |
|
167 | |||
168 | /** |
||
169 | * Store the restore hook events |
||
170 | * @param string $path Path of the file that has been restored |
||
171 | */ |
||
172 | 1 | public function fileRestore($path) { |
|
175 | |||
176 | /** |
||
177 | * Creates the entries for file actions on $file_path |
||
178 | * |
||
179 | * @param string $filePath The file that is being changed |
||
180 | * @param int $activityType The activity type |
||
181 | * @param string $subject The subject for the actor |
||
182 | * @param string $subjectBy The subject for other users (with "by $actor") |
||
183 | */ |
||
184 | 3 | protected function addNotificationsForFileAction($filePath, $activityType, $subject, $subjectBy) { |
|
185 | // Do not add activities for .part-files |
||
186 | 3 | if (substr($filePath, -5) === '.part') { |
|
187 | 1 | return; |
|
188 | } |
||
189 | |||
190 | 2 | list($filePath, $uidOwner, $fileId) = $this->getSourcePathAndOwner($filePath); |
|
191 | 2 | if ($fileId === 0) { |
|
192 | // Could not find the file for the owner ... |
||
193 | return; |
||
194 | } |
||
195 | |||
196 | 2 | $accessList = $this->getUserPathsFromPath($filePath, $uidOwner); |
|
197 | |||
198 | 2 | $this->generateRemoteActivity($accessList['remotes'], $activityType, time(), $this->currentUser->getCloudId(), $accessList['ownerPath']); |
|
199 | |||
200 | 2 | $affectedUsers = $accessList['users']; |
|
201 | 2 | $filteredStreamUsers = $this->userSettings->filterUsersBySetting(array_keys($affectedUsers), 'stream', $activityType); |
|
202 | 2 | $filteredEmailUsers = $this->userSettings->filterUsersBySetting(array_keys($affectedUsers), 'email', $activityType); |
|
203 | |||
204 | 2 | foreach ($affectedUsers as $user => $path) { |
|
205 | 2 | $user = (string) $user; |
|
206 | 2 | if (empty($filteredStreamUsers[$user]) && empty($filteredEmailUsers[$user])) { |
|
207 | 2 | continue; |
|
208 | } |
||
209 | |||
210 | 2 | if ($user === $this->currentUser->getUID()) { |
|
211 | 1 | $userSubject = $subject; |
|
212 | 1 | $userParams = [[$fileId => $path]]; |
|
213 | } else { |
||
214 | 1 | $userSubject = $subjectBy; |
|
215 | 1 | $userParams = [[$fileId => $path], $this->currentUser->getUserIdentifier()]; |
|
216 | } |
||
217 | |||
218 | 2 | $this->addNotificationsForUser( |
|
219 | 2 | $user, $userSubject, $userParams, |
|
220 | 2 | $fileId, $path, true, |
|
221 | 2 | !empty($filteredStreamUsers[$user]), |
|
222 | 2 | $filteredEmailUsers[$user] ?? false, |
|
223 | 2 | $activityType |
|
224 | ); |
||
225 | } |
||
226 | 2 | } |
|
227 | |||
228 | 2 | protected function generateRemoteActivity(array $remoteUsers, $type, $time, $actor, $ownerPath = false) { |
|
251 | |||
252 | /** |
||
253 | * Collect some information for move/renames |
||
254 | * |
||
255 | * @param string $oldPath Path of the file that has been moved |
||
256 | * @param string $newPath Path of the file that has been moved |
||
257 | */ |
||
258 | public function fileMove($oldPath, $newPath) { |
||
321 | |||
322 | |||
323 | /** |
||
324 | * Store the move hook events |
||
325 | * |
||
326 | * @param string $oldPath Path of the file that has been moved |
||
327 | * @param string $newPath Path of the file that has been moved |
||
328 | */ |
||
329 | public function fileMovePost($oldPath, $newPath) { |
||
348 | |||
349 | |||
350 | /** |
||
351 | * Renaming a file inside the same folder (a/b to a/c) |
||
352 | * |
||
353 | * @param string $oldPath |
||
354 | * @param string $newPath |
||
355 | */ |
||
356 | protected function fileRenaming($oldPath, $newPath) { |
||
357 | $dirName = dirname($newPath); |
||
358 | $fileName = basename($newPath); |
||
359 | $oldFileName = basename($oldPath); |
||
360 | |||
361 | list(, , $fileId) = $this->getSourcePathAndOwner($newPath); |
||
362 | list($parentPath, $parentOwner, $parentId) = $this->getSourcePathAndOwner($dirName); |
||
363 | if ($fileId === 0 || $parentId === 0) { |
||
364 | // Could not find the file for the owner ... |
||
365 | return; |
||
366 | } |
||
367 | $accessList = $this->getUserPathsFromPath($parentPath, $parentOwner); |
||
368 | |||
369 | $renameRemotes = []; |
||
370 | foreach ($accessList['remotes'] as $remote => $info) { |
||
371 | $renameRemotes[$remote] = [ |
||
372 | 'token' => $info['token'], |
||
373 | 'node_path' => substr($newPath, strlen($info['node_path'])), |
||
374 | 'second_path' => substr($oldPath, strlen($info['node_path'])), |
||
375 | ]; |
||
376 | } |
||
377 | $this->generateRemoteActivity($renameRemotes, Files::TYPE_SHARE_CHANGED, time(), $this->currentUser->getCloudId()); |
||
378 | |||
379 | $affectedUsers = $accessList['users']; |
||
380 | $filteredStreamUsers = $this->userSettings->filterUsersBySetting(array_keys($affectedUsers), 'stream', Files::TYPE_SHARE_CHANGED); |
||
381 | $filteredEmailUsers = $this->userSettings->filterUsersBySetting(array_keys($affectedUsers), 'email', Files::TYPE_SHARE_CHANGED); |
||
382 | |||
383 | foreach ($affectedUsers as $user => $path) { |
||
384 | if (empty($filteredStreamUsers[$user]) && empty($filteredEmailUsers[$user])) { |
||
385 | continue; |
||
386 | } |
||
387 | |||
388 | if ($user === $this->currentUser->getUID()) { |
||
389 | $userSubject = 'renamed_self'; |
||
390 | $userParams = [ |
||
391 | [$fileId => $path . '/' . $fileName], |
||
392 | [$fileId => $path . '/' . $oldFileName], |
||
393 | ]; |
||
394 | } else { |
||
395 | $userSubject = 'renamed_by'; |
||
396 | $userParams = [ |
||
397 | [$fileId => $path . '/' . $fileName], |
||
398 | $this->currentUser->getUserIdentifier(), |
||
399 | [$fileId => $path . '/' . $oldFileName], |
||
400 | ]; |
||
401 | } |
||
402 | |||
403 | $this->addNotificationsForUser( |
||
404 | $user, $userSubject, $userParams, |
||
405 | $fileId, $path . '/' . $fileName, true, |
||
406 | !empty($filteredStreamUsers[$user]), |
||
407 | $filteredEmailUsers[$user] ?? false, |
||
408 | Files::TYPE_SHARE_CHANGED |
||
409 | ); |
||
410 | } |
||
411 | } |
||
412 | |||
413 | /** |
||
414 | * Moving a file from one folder to another |
||
415 | * |
||
416 | * @param string $oldPath |
||
417 | * @param string $newPath |
||
418 | */ |
||
419 | protected function fileMoving($oldPath, $newPath) { |
||
473 | |||
474 | /** |
||
475 | * @param string[] $users |
||
476 | * @param string[] $pathMap |
||
477 | * @param int $fileId |
||
478 | * @param string $oldFileName |
||
479 | */ |
||
480 | View Code Duplication | protected function generateDeleteActivities($users, $pathMap, $fileId, $oldFileName) { |
|
|
|||
481 | if (empty($users)) { |
||
482 | return; |
||
483 | } |
||
484 | |||
485 | $filteredStreamUsers = $this->userSettings->filterUsersBySetting($users, 'stream', Files::TYPE_SHARE_DELETED); |
||
486 | $filteredEmailUsers = $this->userSettings->filterUsersBySetting($users, 'email', Files::TYPE_SHARE_DELETED); |
||
487 | |||
488 | foreach ($users as $user) { |
||
489 | if (empty($filteredStreamUsers[$user]) && empty($filteredEmailUsers[$user])) { |
||
490 | continue; |
||
491 | } |
||
492 | |||
493 | $path = $pathMap[$user]; |
||
494 | |||
495 | if ($user === $this->currentUser->getUID()) { |
||
496 | $userSubject = 'deleted_self'; |
||
497 | $userParams = [[$fileId => $path . '/' . $oldFileName]]; |
||
498 | } else { |
||
499 | $userSubject = 'deleted_by'; |
||
500 | $userParams = [[$fileId => $path . '/' . $oldFileName], $this->currentUser->getUserIdentifier()]; |
||
501 | } |
||
502 | |||
503 | $this->addNotificationsForUser( |
||
504 | $user, $userSubject, $userParams, |
||
505 | $fileId, $path . '/' . $oldFileName, true, |
||
506 | !empty($filteredStreamUsers[$user]), |
||
507 | $filteredEmailUsers[$user] ?? false, |
||
508 | Files::TYPE_SHARE_DELETED |
||
509 | ); |
||
510 | } |
||
511 | } |
||
512 | |||
513 | /** |
||
514 | * @param string[] $users |
||
515 | * @param string[] $pathMap |
||
516 | * @param int $fileId |
||
517 | * @param string $fileName |
||
518 | */ |
||
519 | View Code Duplication | protected function generateAddActivities($users, $pathMap, $fileId, $fileName) { |
|
520 | if (empty($users)) { |
||
521 | return; |
||
522 | } |
||
523 | |||
524 | $filteredStreamUsers = $this->userSettings->filterUsersBySetting($users, 'stream', Files::TYPE_SHARE_CREATED); |
||
525 | $filteredEmailUsers = $this->userSettings->filterUsersBySetting($users, 'email', Files::TYPE_SHARE_CREATED); |
||
526 | |||
527 | foreach ($users as $user) { |
||
528 | if (empty($filteredStreamUsers[$user]) && empty($filteredEmailUsers[$user])) { |
||
529 | continue; |
||
530 | } |
||
531 | |||
532 | $path = $pathMap[$user]; |
||
533 | |||
534 | if ($user === $this->currentUser->getUID()) { |
||
535 | $userSubject = 'created_self'; |
||
536 | $userParams = [[$fileId => $path . '/' . $fileName]]; |
||
537 | } else { |
||
538 | $userSubject = 'created_by'; |
||
539 | $userParams = [[$fileId => $path . '/' . $fileName], $this->currentUser->getUserIdentifier()]; |
||
540 | } |
||
541 | |||
542 | $this->addNotificationsForUser( |
||
543 | $user, $userSubject, $userParams, |
||
544 | $fileId, $path . '/' . $fileName, true, |
||
545 | !empty($filteredStreamUsers[$user]), |
||
546 | $filteredEmailUsers[$user] ?? false, |
||
547 | Files::TYPE_SHARE_CREATED |
||
548 | ); |
||
549 | } |
||
550 | } |
||
551 | |||
552 | /** |
||
553 | * @param string[] $users |
||
554 | * @param string[] $beforePathMap |
||
555 | * @param string[] $afterPathMap |
||
556 | * @param int $fileId |
||
557 | * @param string $oldFileName |
||
558 | * @param int $newParentId |
||
559 | * @param string $fileName |
||
560 | */ |
||
561 | protected function generateMoveActivities($users, $beforePathMap, $afterPathMap, $fileId, $oldFileName, $newParentId, $fileName) { |
||
562 | if (empty($users)) { |
||
563 | return; |
||
564 | } |
||
565 | |||
566 | $filteredStreamUsers = $this->userSettings->filterUsersBySetting($users, 'stream', Files::TYPE_SHARE_CHANGED); |
||
567 | $filteredEmailUsers = $this->userSettings->filterUsersBySetting($users, 'email', Files::TYPE_SHARE_CHANGED); |
||
568 | |||
569 | foreach ($users as $user) { |
||
570 | if (empty($filteredStreamUsers[$user]) && empty($filteredEmailUsers[$user])) { |
||
571 | continue; |
||
572 | } |
||
573 | |||
574 | if ($oldFileName === $fileName) { |
||
575 | $userParams = [[$newParentId => $afterPathMap[$user] . '/']]; |
||
576 | } else { |
||
577 | $userParams = [[$fileId => $afterPathMap[$user] . '/' . $fileName]]; |
||
578 | } |
||
579 | |||
580 | if ($user === $this->currentUser->getUID()) { |
||
581 | $userSubject = 'moved_self'; |
||
582 | } else { |
||
583 | $userSubject = 'moved_by'; |
||
584 | $userParams[] = $this->currentUser->getUserIdentifier(); |
||
585 | } |
||
586 | $userParams[] = [$fileId => $beforePathMap[$user] . '/' . $oldFileName]; |
||
587 | |||
588 | $this->addNotificationsForUser( |
||
589 | $user, $userSubject, $userParams, |
||
590 | $fileId, $afterPathMap[$user] . '/' . $fileName, true, |
||
591 | !empty($filteredStreamUsers[$user]), |
||
592 | $filteredEmailUsers[$user] ?? false, |
||
593 | Files::TYPE_SHARE_CHANGED |
||
594 | ); |
||
595 | } |
||
596 | } |
||
597 | |||
598 | /** |
||
599 | * Returns a "username => path" map for all affected users |
||
600 | * |
||
601 | * @param string $path |
||
602 | * @param string $uidOwner |
||
603 | * @return array |
||
604 | */ |
||
605 | protected function getUserPathsFromPath($path, $uidOwner) { |
||
629 | |||
630 | /** |
||
631 | * Return the source |
||
632 | * |
||
633 | * @param string $path |
||
634 | * @return array |
||
635 | */ |
||
636 | protected function getSourcePathAndOwner($path) { |
||
669 | |||
670 | /** |
||
671 | * Manage sharing events |
||
672 | * @param array $params The hook params |
||
673 | */ |
||
674 | 3 | public function share($params) { |
|
685 | |||
686 | /** |
||
687 | * Sharing a file or folder with a user |
||
688 | * |
||
689 | * @param string $shareWith |
||
690 | * @param int $fileSource File ID that is being shared |
||
691 | * @param string $itemType File type that is being shared (file or folder) |
||
692 | * @param string $fileTarget File path |
||
693 | */ |
||
694 | 2 | protected function shareWithUser($shareWith, $fileSource, $itemType, $fileTarget) { |
|
709 | |||
710 | /** |
||
711 | * Sharing a file or folder with a group |
||
712 | * |
||
713 | * @param string $shareWith |
||
714 | * @param int $fileSource File ID that is being shared |
||
715 | * @param string $itemType File type that is being shared (file or folder) |
||
716 | * @param string $fileTarget File path |
||
717 | * @param int $shareId The Share ID of this share |
||
718 | */ |
||
719 | 6 | protected function shareWithGroup($shareWith, $fileSource, $itemType, $fileTarget, $shareId) { |
|
740 | |||
741 | /** |
||
742 | * Sharing a file or folder via link/public |
||
743 | * |
||
744 | * @param int $fileSource File ID that is being shared |
||
745 | * @param string $itemType File type that is being shared (file or folder) |
||
746 | * @param string $linkOwner |
||
747 | */ |
||
748 | 2 | protected function shareByLink($fileSource, $itemType, $linkOwner) { |
|
766 | |||
767 | /** |
||
768 | * Manage unsharing events |
||
769 | * @param IShare $share |
||
770 | * @throws \OCP\Files\NotFoundException |
||
771 | */ |
||
772 | public function unShare(IShare $share) { |
||
783 | |||
784 | /** |
||
785 | * Unharing a file or folder from a user |
||
786 | * |
||
787 | * @param IShare $share |
||
788 | * @throws \OCP\Files\NotFoundException |
||
789 | */ |
||
790 | protected function unshareFromUser(IShare $share) { |
||
807 | |||
808 | /** |
||
809 | * Unsharing a file or folder from a group |
||
810 | * |
||
811 | * @param IShare $share |
||
812 | * @throws \OCP\Files\NotFoundException |
||
813 | */ |
||
814 | protected function unshareFromGroup(IShare $share) { |
||
835 | |||
836 | /** |
||
837 | * Sharing a file or folder via link/public |
||
838 | * |
||
839 | * @param IShare $share |
||
840 | * @throws \OCP\Files\NotFoundException |
||
841 | */ |
||
842 | protected function unshareLink(IShare $share) { |
||
870 | |||
871 | /** |
||
872 | * @param IUser[] $usersInGroup |
||
873 | * @param string $actionUser |
||
874 | * @param int $fileSource File ID that is being shared |
||
875 | * @param string $itemType File type that is being shared (file or folder) |
||
876 | * @param string $fileTarget File path |
||
877 | * @param int $shareId The Share ID of this share |
||
878 | */ |
||
879 | 4 | protected function addNotificationsForGroupUsers(array $usersInGroup, $actionUser, $fileSource, $itemType, $fileTarget, $shareId) { |
|
880 | 4 | $affectedUsers = []; |
|
881 | |||
882 | 4 | foreach ($usersInGroup as $user) { |
|
883 | 4 | $affectedUsers[$user->getUID()] = $fileTarget; |
|
884 | } |
||
885 | |||
886 | // Remove the triggering user, we already managed his notifications |
||
887 | 4 | unset($affectedUsers[$this->currentUser->getUID()]); |
|
888 | |||
889 | 4 | if (empty($affectedUsers)) { |
|
890 | 1 | return; |
|
891 | } |
||
892 | |||
893 | 3 | $userIds = array_keys($affectedUsers); |
|
894 | 3 | $filteredStreamUsersInGroup = $this->userSettings->filterUsersBySetting($userIds, 'stream', Files_Sharing::TYPE_SHARED); |
|
895 | 3 | $filteredEmailUsersInGroup = $this->userSettings->filterUsersBySetting($userIds, 'email', Files_Sharing::TYPE_SHARED); |
|
896 | |||
897 | 3 | $affectedUsers = $this->fixPathsForShareExceptions($affectedUsers, $shareId); |
|
898 | 3 | foreach ($affectedUsers as $user => $path) { |
|
899 | 3 | if (empty($filteredStreamUsersInGroup[$user]) && empty($filteredEmailUsersInGroup[$user])) { |
|
900 | 2 | continue; |
|
901 | } |
||
902 | |||
903 | 1 | $this->addNotificationsForUser( |
|
904 | 1 | $user, $actionUser, [[$fileSource => $path], $this->currentUser->getUserIdentifier()], |
|
905 | 1 | $fileSource, $path, ($itemType === 'file'), |
|
906 | 1 | !empty($filteredStreamUsersInGroup[$user]), |
|
907 | 1 | $filteredEmailUsersInGroup[$user] ?? false |
|
908 | ); |
||
909 | } |
||
910 | 3 | } |
|
911 | |||
912 | /** |
||
913 | * Check when there was a naming conflict and the target is different |
||
914 | * for some of the users |
||
915 | * |
||
916 | * @param array $affectedUsers |
||
917 | * @param int $shareId |
||
918 | * @return mixed |
||
919 | */ |
||
920 | protected function fixPathsForShareExceptions(array $affectedUsers, $shareId) { |
||
934 | |||
935 | /** |
||
936 | * Add notifications for the user that shares a file/folder |
||
937 | * |
||
938 | * @param string $subject |
||
939 | * @param string $shareWith |
||
940 | * @param int $fileSource |
||
941 | * @param string $itemType |
||
942 | */ |
||
943 | 2 | protected function shareNotificationForSharer($subject, $shareWith, $fileSource, $itemType) { |
|
964 | |||
965 | /** |
||
966 | * Add notifications for the user that shares a file/folder |
||
967 | * |
||
968 | * @param string $owner |
||
969 | * @param string $subject |
||
970 | * @param string $shareWith |
||
971 | * @param int $fileSource |
||
972 | * @param string $itemType |
||
973 | */ |
||
974 | 2 | protected function reshareNotificationForSharer($owner, $subject, $shareWith, $fileSource, $itemType) { |
|
990 | |||
991 | /** |
||
992 | * Add notifications for the owners whose files have been reshared |
||
993 | * |
||
994 | * @param string $currentOwner |
||
995 | * @param string $subject |
||
996 | * @param string $shareWith |
||
997 | * @param int $fileSource |
||
998 | * @param string $itemType |
||
999 | */ |
||
1000 | 10 | protected function shareNotificationForOriginalOwners($currentOwner, $subject, $shareWith, $fileSource, $itemType) { |
|
1040 | |||
1041 | /** |
||
1042 | * Adds the activity and email for a user when the settings require it |
||
1043 | * |
||
1044 | * @param string $user |
||
1045 | * @param string $subject |
||
1046 | * @param array $subjectParams |
||
1047 | * @param int $fileId |
||
1048 | * @param string $path |
||
1049 | * @param bool $isFile If the item is a file, we link to the parent directory |
||
1050 | * @param bool $streamSetting |
||
1051 | * @param int $emailSetting |
||
1052 | * @param string $type |
||
1053 | */ |
||
1054 | 11 | protected function addNotificationsForUser($user, $subject, $subjectParams, $fileId, $path, $isFile, $streamSetting, $emailSetting, $type = Files_Sharing::TYPE_SHARED) { |
|
1096 | } |
||
1097 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.