Code Duplication    Length = 3-5 lines in 5 locations

apps/files_sharing/lib/Controller/ShareAPIController.php 5 locations

@@ 649-653 (lines=5) @@
646
		$userShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_USER, $path, $reshares, -1, 0);
647
		$groupShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_GROUP, $path, $reshares, -1, 0);
648
		$linkShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_LINK, $path, $reshares, -1, 0);
649
		if ($this->shareManager->shareProviderExists(Share::SHARE_TYPE_EMAIL)) {
650
			$mailShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_EMAIL, $path, $reshares, -1, 0);
651
		} else {
652
			$mailShares = [];
653
		}
654
		if ($this->shareManager->shareProviderExists(Share::SHARE_TYPE_CIRCLE)) {
655
			$circleShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_CIRCLE, $path, $reshares, -1, 0);
656
		} else {
@@ 654-658 (lines=5) @@
651
		} else {
652
			$mailShares = [];
653
		}
654
		if ($this->shareManager->shareProviderExists(Share::SHARE_TYPE_CIRCLE)) {
655
			$circleShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_CIRCLE, $path, $reshares, -1, 0);
656
		} else {
657
			$circleShares = [];
658
		}
659
660
		$shares = array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares);
661
@@ 662-665 (lines=4) @@
659
660
		$shares = array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares);
661
662
		if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
663
			$federatedShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_REMOTE, $path, $reshares, -1, 0);
664
			$shares = array_merge($shares, $federatedShares);
665
		}
666
667
		if ($this->shareManager->outgoingServer2ServerGroupSharesAllowed()) {
668
			$federatedShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_REMOTE_GROUP, $path, $reshares, -1, 0);
@@ 571-573 (lines=3) @@
568
			if($this->shareManager->shareProviderExists(Share::SHARE_TYPE_EMAIL)) {
569
				$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_EMAIL, $node, false, -1, 0));
570
			}
571
			if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
572
				$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_REMOTE, $node, false, -1, 0));
573
			}
574
		}
575
576
		$formatted = [];
@@ 667-670 (lines=4) @@
664
			$shares = array_merge($shares, $federatedShares);
665
		}
666
667
		if ($this->shareManager->outgoingServer2ServerGroupSharesAllowed()) {
668
			$federatedShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_REMOTE_GROUP, $path, $reshares, -1, 0);
669
			$shares = array_merge($shares, $federatedShares);
670
		}
671
672
		$formatted = [];
673
		foreach ($shares as $share) {