Code Duplication    Length = 7-7 lines in 3 locations

lib/private/Share/Share.php 3 locations

@@ 734-740 (lines=7) @@
731
			}
732
			if ($shareWithinGroupOnly) {
733
				$inGroup = array_intersect(self::getGroupsForUser($uidOwner), self::getGroupsForUser($shareWith));
734
				if (empty($inGroup)) {
735
					$message = 'Sharing %s failed, because the user '
736
						.'%s is not a member of any groups that %s is a member of';
737
					$message_t = $l->t('Sharing %s failed, because the user %s is not a member of any groups that %s is a member of', [$itemName, $shareWith, $uidOwner]);
738
					\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemName, $shareWith, $uidOwner), \OCP\Util::DEBUG);
739
					throw new \Exception($message_t);
740
				}
741
			}
742
			// Check if the item source is already shared with the user, either from the same owner or a different user
743
			if ($checkExists = self::getItems($itemType, $itemSource, self::$shareTypeUserAndGroups,
@@ 774-780 (lines=7) @@
771
				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
772
				throw new \Exception($message_t);
773
			}
774
			if ($shareWithMembershipGroupOnly && !\OC::$server->getGroupManager()->inGroup($uidOwner, $shareWith)) {
775
				$message = 'Sharing %s failed, because '
776
					.'%s is not a member of the group %s';
777
				$message_t = $l->t('Sharing %s failed, because %s is not a member of the group %s', [$itemSourceName, $uidOwner, $shareWith]);
778
				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $uidOwner, $shareWith), \OCP\Util::DEBUG);
779
				throw new \Exception($message_t);
780
			}
781
			// Check if the item source is already shared with the group, either from the same owner or a different user
782
			// The check for each user in the group is done inside the put() function
783
			if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_GROUP, $shareWith,
@@ 2418-2424 (lines=7) @@
2415
			$result['suggestedFileTarget'] = null;
2416
			$result['itemSource'] = $itemSource;
2417
			$result['expirationDate'] = $expirationDate;
2418
			if (!$backend->isValidSource($itemSource, $uidOwner)) {
2419
				$message = 'Sharing %s failed, because the sharing backend for '
2420
					.'%s could not find its source';
2421
				$message_t = $l->t('Sharing %s failed, because the sharing backend for %s could not find its source', [$itemSource, $itemType]);
2422
				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSource, $itemType), \OCP\Util::DEBUG);
2423
				throw new \Exception($message_t);
2424
			}
2425
			if ($backend instanceof \OCP\Share_Backend_File_Dependent) {
2426
				$result['filePath'] = $backend->getFilePath($itemSource, $uidOwner);
2427
				if ($itemType == 'file' || $itemType == 'folder') {