Code Duplication    Length = 12-12 lines in 2 locations

lib/private/Share/Share.php 2 locations

@@ 661-672 (lines=12) @@
658
				}
659
			}
660
			// Check if the item source is already shared with the user, either from the same owner or a different user
661
			if ($checkExists = self::getItems($itemType, $itemSource, self::$shareTypeUserAndGroups,
662
				$shareWith, null, self::FORMAT_NONE, null, 1, true, true)) {
663
				// Only allow the same share to occur again if it is the same
664
				// owner and is not a user share, this use case is for increasing
665
				// permissions for a specific user
666
				if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) {
667
					$message = 'Sharing %s failed, because this item is already shared with %s';
668
					$message_t = $l->t('Sharing %s failed, because this item is already shared with %s', [$itemSourceName, $shareWith]);
669
					\OCP\Util::writeLog('OCP\Share', \sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
670
					throw new \Exception($message_t);
671
				}
672
			}
673
			if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_USER,
674
				$shareWith, null, self::FORMAT_NONE, null, 1, true, true)) {
675
				// Only allow the same share to occur again if it is the same
@@ 673-684 (lines=12) @@
670
					throw new \Exception($message_t);
671
				}
672
			}
673
			if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_USER,
674
				$shareWith, null, self::FORMAT_NONE, null, 1, true, true)) {
675
				// Only allow the same share to occur again if it is the same
676
				// owner and is not a user share, this use case is for increasing
677
				// permissions for a specific user
678
				if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) {
679
					$message = 'Sharing %s failed, because this item is already shared with user %s';
680
					$message_t = $l->t('Sharing %s failed, because this item is already shared with user %s', [$itemSourceName, $shareWith]);
681
					\OCP\Util::writeLog('OCP\Share', \sprintf($message, $itemSourceName, $shareWith), \OCP\Util::ERROR);
682
					throw new \Exception($message_t);
683
				}
684
			}
685
		} elseif ($shareType === self::SHARE_TYPE_GROUP) {
686
			if (!\OC::$server->getGroupManager()->groupExists($shareWith)) {
687
				$message = 'Sharing %s failed, because the group %s does not exist';