Code Duplication    Length = 6-7 lines in 3 locations

lib/Fixtures/ShareFix.php 3 locations

@@ 281-286 (lines=6) @@
278
		$backend = self::getBackend($itemType);
279
		$l = \OC::$server->getL10N('lib');
280
281
		if ($backend->isShareTypeAllowed($shareType) === false) {
282
			$message = 'Sharing %s failed, because the backend does not allow shares from type %i';
283
			$message_t = $l->t('Sharing %s failed, because the backend does not allow shares from type %i', array($itemSourceName, $shareType));
284
			self::log('NextNote\Fixtures\ShareFix', sprintf($message, $itemSourceName, $shareType), \OCP\Util::DEBUG);
285
			throw new \Exception($message_t);
286
		}
287
288
		$uidOwner = \OC_User::getUser();
289
		$shareWithinGroupOnly = self::shareWithGroupMembersOnly();
@@ 339-345 (lines=7) @@
336
					$groupsShareWith = $groupManager->getUserGroupIds($userShareWith);
337
				}
338
				$inGroup = array_intersect($groupsOwner, $groupsShareWith);
339
				if (empty($inGroup)) {
340
					$message = 'Sharing %s failed, because the user '
341
						. '%s is not a member of any groups that %s is a member of';
342
					$message_t = $l->t('Sharing %s failed, because the user %s is not a member of any groups that %s is a member of', array($itemName, $shareWith, $uidOwner));
343
					self::log('NextNote\Fixtures\ShareFix', sprintf($message, $itemName, $shareWith, $uidOwner), \OCP\Util::DEBUG);
344
					throw new \Exception($message_t);
345
				}
346
			}
347
			// Check if the item source is already shared with the user, either from the same owner or a different user
348
			if ($checkExists = self::getItems($itemType, $itemSource, self::$shareTypeUserAndGroups,
@@ 733-739 (lines=7) @@
730
			$result['suggestedFileTarget'] = null;
731
			$result['itemSource'] = $itemSource;
732
			$result['expirationDate'] = $expirationDate;
733
			if (!$backend->isValidSource($itemSource, $uidOwner)) {
734
				$message = 'Sharing %s failed, because the sharing backend for '
735
					. '%s could not find its source';
736
				$message_t = $l->t('Sharing %s failed, because the sharing backend for %s could not find its source', array($itemSource, $itemType));
737
				self::log('NextNote\Fixtures\ShareFix', sprintf($message, $itemSource, $itemType), \OCP\Util::DEBUG);
738
				throw new \Exception($message_t);
739
			}
740
			if ($backend instanceof \OCP\Share_Backend_File_Dependent) {
741
				$result['filePath'] = $backend->getFilePath($itemSource, $uidOwner);
742
				if ($itemType == 'file' || $itemType == 'folder') {