Code Duplication    Length = 3-3 lines in 7 locations

lib/private/Share/Share.php 7 locations

@@ 88-90 (lines=3) @@
85
	 */
86
	public static function registerBackend($itemType, $class, $collectionOf = null, $supportedFileExtensions = null) {
87
		if (self::isEnabled()) {
88
			if ($itemType === 'file' || $itemType === 'folder') {
89
				throw new \InvalidArgumentException('Item type "' . $itemType . '" not supported by old share API any more');
90
			}
91
			if (!isset(self::$backendTypes[$itemType])) {
92
				self::$backendTypes[$itemType] = [
93
					'class' => $class,
@@ 386-388 (lines=3) @@
383
	 * @return array Return list of items with item_target, permissions and expiration
384
	 */
385
	public static function getItemSharedWithUser($itemType, $itemSource, $user, $owner = null, $shareType = null) {
386
		if ($itemType === 'file' || $itemType === 'folder') {
387
			throw new \InvalidArgumentException('Item type "' . $itemType . '" not supported by old share API any more');
388
		}
389
		$shares = [];
390
391
		$where = 'WHERE';
@@ 936-938 (lines=3) @@
933
	 * Unsharing from self is not allowed for items inside collections
934
	 */
935
	public static function unshareFromSelf($itemType, $itemOrigin, $originIsSource = false) {
936
		if ($itemType === 'file' || $itemType === 'folder') {
937
			throw new \InvalidArgumentException('Item type "' . $itemType . '" not supported by old share API any more');
938
		}
939
		$originType = ($originIsSource) ? 'source' : 'target';
940
		$uid = \OCP\User::getUser();
941
@@ 1591-1593 (lines=3) @@
1588
		if (!self::isEnabled()) {
1589
			return [];
1590
		}
1591
		if ($itemType === 'file' || $itemType === 'folder') {
1592
			throw new \InvalidArgumentException('Item type "' . $itemType . '" not supported by old share API any more');
1593
		}
1594
		$backend = self::getBackend($itemType);
1595
		$collectionTypes = false;
1596
		// Get filesystem root to add it to the file target and remove from the
@@ 1926-1928 (lines=3) @@
1923
	 * @return array of grouped items
1924
	 */
1925
	protected static function groupItems($items, $itemType) {
1926
		if ($itemType === 'file' || $itemType === 'folder') {
1927
			throw new \InvalidArgumentException('Item type "' . $itemType . '" not supported by old share API any more');
1928
		}
1929
		$fileSharing = false;
1930
1931
		$result = [];
@@ 1977-1979 (lines=3) @@
1974
	 */
1975
	private static function put($itemType, $itemSource, $shareType, $shareWith, $uidOwner,
1976
								$permissions, $parentFolder = null, $token = null, $itemSourceName = null, \DateTime $expirationDate = null) {
1977
		if ($itemType === 'file' || $itemType === 'folder') {
1978
			throw new \InvalidArgumentException('Item type "' . $itemType . '" not supported by old share API any more');
1979
		}
1980
1981
		$queriesToExecute = [];
1982
		$suggestedItemTarget = null;
@@ 2152-2154 (lines=3) @@
2149
	 * @param null|\DateTime $expirationDate
2150
	 */
2151
	private static function checkReshare($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, $itemSourceName, $expirationDate) {
2152
		if ($itemType === 'file' || $itemType === 'folder') {
2153
			throw new \InvalidArgumentException('Item type "' . $itemType . '" not supported by old share API any more');
2154
		}
2155
		$backend = self::getBackend($itemType);
2156
2157
		$l = \OC::$server->getL10N('lib');