Code Duplication    Length = 25-26 lines in 2 locations

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

@@ 119-143 (lines=25) @@
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
			\OCP\Share::SHARE_TYPE_ROOM,
128
		];
129
		foreach ($requestedShareTypes as $requestedShareType) {
130
			// one of each type is enough to find out about the types
131
			$shares = $this->shareManager->getSharesBy(
132
				$this->userId,
133
				$requestedShareType,
134
				$node,
135
				false,
136
				1
137
			);
138
			if (!empty($shares)) {
139
				$shareTypes[] = $requestedShareType;
140
			}
141
		}
142
		return $shareTypes;
143
	}
144
145
	private function getSharesTypesInFolder(\OCP\Files\Folder $node) {
146
		$shares = $this->shareManager->getSharesInFolder(

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

@@ 209-234 (lines=26) @@
206
	 *
207
	 * @return int[] array of share types
208
	 */
209
	private function getShareTypes(Node $node) {
210
		$userId = $this->userSession->getUser()->getUID();
211
		$shareTypes = [];
212
		$requestedShareTypes = [
213
			\OCP\Share::SHARE_TYPE_USER,
214
			\OCP\Share::SHARE_TYPE_GROUP,
215
			\OCP\Share::SHARE_TYPE_LINK,
216
			\OCP\Share::SHARE_TYPE_REMOTE,
217
			\OCP\Share::SHARE_TYPE_EMAIL,
218
			\OCP\Share::SHARE_TYPE_ROOM
219
		];
220
		foreach ($requestedShareTypes as $requestedShareType) {
221
			// one of each type is enough to find out about the types
222
			$shares = $this->shareManager->getSharesBy(
223
				$userId,
224
				$requestedShareType,
225
				$node,
226
				false,
227
				1
228
			);
229
			if (!empty($shares)) {
230
				$shareTypes[] = $requestedShareType;
231
			}
232
		}
233
		return $shareTypes;
234
	}
235
236
	/**
237
	 * Change the default sort mode