Code Duplication    Length = 24-25 lines in 2 locations

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

@@ 209-233 (lines=25) @@
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
		];
219
		foreach ($requestedShareTypes as $requestedShareType) {
220
			// one of each type is enough to find out about the types
221
			$shares = $this->shareManager->getSharesBy(
222
				$userId,
223
				$requestedShareType,
224
				$node,
225
				false,
226
				1
227
			);
228
			if (!empty($shares)) {
229
				$shareTypes[] = $requestedShareType;
230
			}
231
		}
232
		return $shareTypes;
233
	}
234
235
	/**
236
	 * Change the default sort mode

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(