Code Duplication    Length = 17-18 lines in 4 locations

apps/sharebymail/lib/ShareByMailProvider.php 2 locations

@@ 579-596 (lines=18) @@
576
	 * @param IShare $parent
577
	 * @return IShare[]
578
	 */
579
	public function getChildren(IShare $parent) {
580
		$children = [];
581
582
		$qb = $this->dbConnection->getQueryBuilder();
583
		$qb->select('*')
584
			->from('share')
585
			->where($qb->expr()->eq('parent', $qb->createNamedParameter($parent->getId())))
586
			->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)))
587
			->orderBy('id');
588
589
		$cursor = $qb->execute();
590
		while($data = $cursor->fetch()) {
591
			$children[] = $this->createShareObject($data);
592
		}
593
		$cursor->closeCursor();
594
595
		return $children;
596
	}
597
598
	/**
599
	 * add share to the database and return the ID
@@ 790-806 (lines=17) @@
787
	 * @param \OCP\Files\Node $path
788
	 * @return IShare[]
789
	 */
790
	public function getSharesByPath(Node $path) {
791
		$qb = $this->dbConnection->getQueryBuilder();
792
793
		$cursor = $qb->select('*')
794
			->from('share')
795
			->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($path->getId())))
796
			->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)))
797
			->execute();
798
799
		$shares = [];
800
		while($data = $cursor->fetch()) {
801
			$shares[] = $this->createShareObject($data);
802
		}
803
		$cursor->closeCursor();
804
805
		return $shares;
806
	}
807
808
	/**
809
	 * @inheritdoc

apps/federatedfilesharing/lib/FederatedShareProvider.php 2 locations

@@ 511-528 (lines=18) @@
508
	 * @param IShare $parent
509
	 * @return IShare[]
510
	 */
511
	public function getChildren(IShare $parent) {
512
		$children = [];
513
514
		$qb = $this->dbConnection->getQueryBuilder();
515
		$qb->select('*')
516
			->from('share')
517
			->where($qb->expr()->eq('parent', $qb->createNamedParameter($parent->getId())))
518
			->andWhere($qb->expr()->in('share_type', $qb->createNamedParameter($this->supportedShareType, IQueryBuilder::PARAM_INT_ARRAY)))
519
			->orderBy('id');
520
521
		$cursor = $qb->execute();
522
		while($data = $cursor->fetch()) {
523
			$children[] = $this->createShareObject($data);
524
		}
525
		$cursor->closeCursor();
526
527
		return $children;
528
	}
529
530
	/**
531
	 * Delete a share (owner unShares the file)
@@ 749-766 (lines=18) @@
746
	 * @param \OCP\Files\Node $path
747
	 * @return IShare[]
748
	 */
749
	public function getSharesByPath(Node $path) {
750
		$qb = $this->dbConnection->getQueryBuilder();
751
752
		// get federated user shares
753
		$cursor = $qb->select('*')
754
			->from('share')
755
			->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($path->getId())))
756
			->andWhere($qb->expr()->in('share_type', $qb->createNamedParameter($this->supportedShareType, IQueryBuilder::PARAM_INT_ARRAY)))
757
			->execute();
758
759
		$shares = [];
760
		while($data = $cursor->fetch()) {
761
			$shares[] = $this->createShareObject($data);
762
		}
763
		$cursor->closeCursor();
764
765
		return $shares;
766
	}
767
768
	/**
769
	 * @inheritdoc