Code Duplication    Length = 6-6 lines in 3 locations

lib/private/Share/Share.php 3 locations

@@ 644-649 (lines=6) @@
641
				\OCP\Util::writeLog('OCP\Share', \sprintf($message, $itemSourceName), \OCP\Util::DEBUG);
642
				throw new \Exception($message_t);
643
			}
644
			if (!\OC_User::userExists($shareWith)) {
645
				$message = 'Sharing %s failed, because the user %s does not exist';
646
				$message_t = $l->t('Sharing %s failed, because the user %s does not exist', [$itemSourceName, $shareWith]);
647
				\OCP\Util::writeLog('OCP\Share', \sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
648
				throw new \Exception($message_t);
649
			}
650
			if ($shareWithinGroupOnly) {
651
				$inGroup = \array_intersect(self::getGroupsForUser($uidOwner), self::getGroupsForUser($shareWith));
652
				if (empty($inGroup)) {
@@ 814-819 (lines=6) @@
811
			list($user, $remote) = Helper::splitUserRemote($shareWith);
812
			$currentServer = self::removeProtocolFromUrl(\OC::$server->getURLGenerator()->getAbsoluteURL('/'));
813
			$currentUser = \OC::$server->getUserSession()->getUser()->getUID();
814
			if (Helper::isSameUserOnSameServer($user, $remote, $currentUser, $currentServer)) {
815
				$message = 'Not allowed to create a federated share with the same user.';
816
				$message_t = $l->t('Not allowed to create a federated share with the same user');
817
				\OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::DEBUG);
818
				throw new \Exception($message_t);
819
			}
820
821
			$token = \OC::$server->getSecureRandom()->generate(self::TOKEN_LENGTH, \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER .
822
				\OCP\Security\ISecureRandom::CHAR_DIGITS);
@@ 1455-1460 (lines=6) @@
1452
			$class = self::$backendTypes[$itemType]['class'];
1453
			if (\class_exists($class)) {
1454
				self::$backends[$itemType] = new $class;
1455
				if (!(self::$backends[$itemType] instanceof \OCP\Share_Backend)) {
1456
					$message = 'Sharing backend %s must implement the interface OCP\Share_Backend';
1457
					$message_t = $l->t('Sharing backend %s must implement the interface OCP\Share_Backend', [$class]);
1458
					\OCP\Util::writeLog('OCP\Share', \sprintf($message, $class), \OCP\Util::ERROR);
1459
					throw new \Exception($message_t);
1460
				}
1461
				return self::$backends[$itemType];
1462
			} else {
1463
				$message = 'Sharing backend %s not found';