Code Duplication    Length = 20-20 lines in 2 locations

apps/files_sharing/lib/Activity/Providers/Base.php 1 location

@@ 135-154 (lines=20) @@
132
	 * @return array
133
	 * @throws \InvalidArgumentException
134
	 */
135
	protected function getFile($parameter, IEvent $event = null) {
136
		if (is_array($parameter)) {
137
			$path = reset($parameter);
138
			$id = (string) key($parameter);
139
		} else if ($event !== null) {
140
			// Legacy from before ownCloud 8.2
141
			$path = $parameter;
142
			$id = $event->getObjectId();
143
		} else {
144
			throw new \InvalidArgumentException('Could not generate file parameter');
145
		}
146
147
		return [
148
			'type' => 'file',
149
			'id' => $id,
150
			'name' => basename($path),
151
			'path' => trim($path, '/'),
152
			'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $id]),
153
		];
154
	}
155
156
	/**
157
	 * @param string $uid

apps/files/lib/Activity/Provider.php 1 location

@@ 349-368 (lines=20) @@
346
	 * @return array
347
	 * @throws \InvalidArgumentException
348
	 */
349
	protected function getFile($parameter, IEvent $event = null) {
350
		if (is_array($parameter)) {
351
			$path = reset($parameter);
352
			$id = (string) key($parameter);
353
		} else if ($event !== null) {
354
			// Legacy from before ownCloud 8.2
355
			$path = $parameter;
356
			$id = $event->getObjectId();
357
		} else {
358
			throw new \InvalidArgumentException('Could not generate file parameter');
359
		}
360
361
		return [
362
			'type' => 'file',
363
			'id' => $id,
364
			'name' => basename($path),
365
			'path' => trim($path, '/'),
366
			'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $id]),
367
		];
368
	}
369
370
	/**
371
	 * @param string $uid