Code Duplication    Length = 24-25 lines in 2 locations

apps/dav/lib/Connector/Sabre/SharesPlugin.php 1 location

@@ 119-142 (lines=24) @@
116
	 *
117
	 * @return int[] array of share types
118
	 */
119
	private function getShareTypes(\OCP\Files\Node $node) {
120
		$shareTypes = [];
121
		$requestedShareTypes = [
122
			\OCP\Share::SHARE_TYPE_USER,
123
			\OCP\Share::SHARE_TYPE_GROUP,
124
			\OCP\Share::SHARE_TYPE_LINK,
125
			\OCP\Share::SHARE_TYPE_REMOTE,
126
			\OCP\Share::SHARE_TYPE_EMAIL,
127
		];
128
		foreach ($requestedShareTypes as $requestedShareType) {
129
			// one of each type is enough to find out about the types
130
			$shares = $this->shareManager->getSharesBy(
131
				$this->userId,
132
				$requestedShareType,
133
				$node,
134
				false,
135
				1
136
			);
137
			if (!empty($shares)) {
138
				$shareTypes[] = $requestedShareType;
139
			}
140
		}
141
		return $shareTypes;
142
	}
143
144
	private function getSharesTypesInFolder(\OCP\Files\Folder $node) {
145
		$shares = $this->shareManager->getSharesInFolder(

apps/files/lib/Controller/ApiController.php 1 location

@@ 233-257 (lines=25) @@
230
	 *
231
	 * @return int[] array of share types
232
	 */
233
	private function getShareTypes(Node $node) {
234
		$userId = $this->userSession->getUser()->getUID();
235
		$shareTypes = [];
236
		$requestedShareTypes = [
237
			\OCP\Share::SHARE_TYPE_USER,
238
			\OCP\Share::SHARE_TYPE_GROUP,
239
			\OCP\Share::SHARE_TYPE_LINK,
240
			\OCP\Share::SHARE_TYPE_REMOTE,
241
			\OCP\Share::SHARE_TYPE_EMAIL
242
		];
243
		foreach ($requestedShareTypes as $requestedShareType) {
244
			// one of each type is enough to find out about the types
245
			$shares = $this->shareManager->getSharesBy(
246
				$userId,
247
				$requestedShareType,
248
				$node,
249
				false,
250
				1
251
			);
252
			if (!empty($shares)) {
253
				$shareTypes[] = $requestedShareType;
254
			}
255
		}
256
		return $shareTypes;
257
	}
258
259
	/**
260
	 * Change the default sort mode