Code Duplication    Length = 6-7 lines in 5 locations

lib/private/Share/Share.php 5 locations

@@ 638-643 (lines=6) @@
635
636
		// Verify share type and sharing conditions are met
637
		if ($shareType === self::SHARE_TYPE_USER) {
638
			if ($shareWith == $uidOwner) {
639
				$message = 'Sharing %s failed, because you can not share with yourself';
640
				$message_t = $l->t('Sharing %s failed, because you can not share with yourself', [$itemName]);
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]);
@@ 840-846 (lines=7) @@
837
			}
838
839
			return $send;
840
		} else {
841
			// Future share types need to include their own conditions
842
			$message = 'Share type %s is not valid for %s';
843
			$message_t = $l->t('Share type %s is not valid for %s', [$shareType, $itemSource]);
844
			\OCP\Util::writeLog('OCP\Share', \sprintf($message, $shareType, $itemSource), \OCP\Util::DEBUG);
845
			throw new \Exception($message_t);
846
		}
847
848
		// Put the item into the database
849
		$result = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, null, null, $itemSourceName, $expirationDate);
@@ 1244-1249 (lines=6) @@
1241
			}
1242
		}
1243
1244
		if ($date < $today) {
1245
			$message = 'Cannot set expiration date. Expiration date is in the past';
1246
			$message_t = $l->t('Cannot set expiration date. Expiration date is in the past');
1247
			\OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::WARN);
1248
			throw new \Exception($message_t);
1249
		}
1250
1251
		return $date;
1252
	}
@@ 1462-1467 (lines=6) @@
1459
					throw new \Exception($message_t);
1460
				}
1461
				return self::$backends[$itemType];
1462
			} else {
1463
				$message = 'Sharing backend %s not found';
1464
				$message_t = $l->t('Sharing backend %s not found', [$class]);
1465
				\OCP\Util::writeLog('OCP\Share', \sprintf($message, $class), \OCP\Util::ERROR);
1466
				throw new \Exception($message_t);
1467
			}
1468
		}
1469
		$message = 'Sharing backend for %s not found';
1470
		$message_t = $l->t('Sharing backend for %s not found', [$itemType]);
@@ 2209-2215 (lines=7) @@
2206
						$result['fileSource'] = null;
2207
					}
2208
				}
2209
			} else {
2210
				$message = 'Sharing %s failed, because resharing is not allowed';
2211
				$message_t = $l->t('Sharing %s failed, because resharing is not allowed', [$itemSourceName]);
2212
2213
				\OCP\Util::writeLog('OCP\Share', \sprintf($message, $itemSourceName), \OCP\Util::DEBUG);
2214
				throw new \Exception($message_t);
2215
			}
2216
		} else {
2217
			$result['parent'] = null;
2218
			$result['suggestedItemTarget'] = null;