Code Duplication    Length = 21-27 lines in 6 locations

lib/Activity/Provider.php 6 locations

@@ 178-204 (lines=27) @@
175
	 *
176
	 * @return IEvent
177
	 */
178
	private function parseCircleCreate($lang, Circle $circle, IEvent $event) {
179
		if ($circle->getOwner()
180
				   ->getUserId() === $this->activityManager->getCurrentUserId()
181
		) {
182
			$event->setRichSubject(
183
				$this->l10n->t('You created the circle {circle}'),
184
				['circle' => $this->generateCircleParameter($circle)]
185
			);
186
187
		} else {
188
			$event->setRichSubject(
189
				$this->l10n->t('{author} created the circle {circle}'),
190
				[
191
					'author' => $author = $this->generateUserParameter(
192
						$circle->getOwner()
193
							   ->getUserId()
194
					),
195
					'circle' => $this->generateCircleParameter($circle)
196
				]
197
			);
198
		}
199
200
		return $event;
201
	}
202
203
204
	/**
205
	 * @param string $lang
206
	 * @param Circle $circle
207
	 * @param IEvent $event
@@ 211-236 (lines=26) @@
208
	 *
209
	 * @return IEvent
210
	 */
211
	private function parseCircleDelete($lang, Circle $circle, IEvent $event) {
212
		if ($circle->getOwner()
213
				   ->getUserId() === $this->activityManager->getCurrentUserId()
214
		) {
215
			$event->setRichSubject(
216
				$this->l10n->t('You deleted {circle}'),
217
				['circle' => $this->generateCircleParameter($circle)]
218
			);
219
		} else {
220
			$event->setRichSubject(
221
				$this->l10n->t('{author} deleted {circle}'),
222
				[
223
					'author' => $this->generateUserParameter(
224
						$circle->getOwner()
225
							   ->getUserId()
226
					),
227
					'circle' => $this->generateCircleParameter($circle)
228
				]
229
			);
230
		}
231
232
		return $event;
233
	}
234
235
236
	/**
237
	 * @param string $lang
238
	 * @param Circle $circle
239
	 * @param Member $member
@@ 295-316 (lines=22) @@
292
	 *
293
	 * @return IEvent
294
	 */
295
	private function parseMemberRequestInvitation(
296
		$lang, Circle $circle, Member $member, IEvent $event
297
	) {
298
		if ($member->getUserId() === $this->activityManager->getCurrentUserId()) {
299
			$event->setRichSubject(
300
				$this->l10n->t('You requested an invitation to {circle}'),
301
				['circle' => $this->generateCircleParameter($circle)]
302
			);
303
304
		} else {
305
			$event->setRichSubject(
306
				$this->l10n->t(
307
					'{author} has requested an invitation into {circle}'
308
				), [
309
					'author' => $this->generateMemberParameter($member),
310
					'circle' => $this->generateCircleParameter($circle)
311
				]
312
			);
313
		}
314
315
		return $event;
316
	}
317
318
319
	/**
@@ 327-348 (lines=22) @@
324
	 *
325
	 * @return IEvent
326
	 */
327
	private function parseMemberJoin($lang, Circle $circle, Member $member, IEvent $event) {
328
		if ($circle->getUser()
329
				   ->getUserId() === $this->activityManager->getCurrentUserId()
330
		) {
331
			$event->setRichSubject(
332
				$this->l10n->t('You joined {circle}'),
333
				['circle' => $this->generateCircleParameter($circle)]
334
			);
335
336
		} else {
337
			$event->setRichSubject(
338
				$this->l10n->t(
339
					'{member} has joined the circle {circle}'
340
				), [
341
					'circle' => $this->generateCircleParameter($circle),
342
					'member' => $this->generateMemberParameter($member)
343
				]
344
			);
345
		}
346
347
		return $event;
348
	}
349
350
351
	/**
@@ 411-432 (lines=22) @@
408
	 *
409
	 * @return IEvent
410
	 */
411
	private function parseMemberLeft($lang, Circle $circle, Member $member, IEvent $event) {
412
		if ($circle->getUser()
413
				   ->getUserId() === $this->activityManager->getCurrentUserId()
414
		) {
415
			$event->setRichSubject(
416
				$this->l10n->t('You left {circle}'),
417
				['circle' => $this->generateCircleParameter($circle)]
418
			);
419
420
		} else {
421
			$event->setRichSubject(
422
				$this->l10n->t(
423
					'{member} has left {circle}'
424
				), [
425
					'circle' => $this->generateCircleParameter($circle),
426
					'member' => $this->generateMemberParameter($member)
427
				]
428
			);
429
		}
430
431
		return $event;
432
	}
433
434
435
	/**
@@ 556-576 (lines=21) @@
553
	 *
554
	 * @return IEvent
555
	 */
556
	private function parseMemberOwner($lang, Circle $circle, Member $member, IEvent $event) {
557
		if ($member->getUserId() === $this->activityManager->getCurrentUserId()
558
		) {
559
			$event->setRichSubject(
560
				$this->l10n->t('You are the new owner of {circle}'),
561
				['circle' => $this->generateCircleParameter($circle)]
562
			);
563
564
		} else {
565
			$event->setRichSubject(
566
				$this->l10n->t(
567
					'{member} is the new owner of {circle}'
568
				), [
569
					'circle' => $this->generateCircleParameter($circle),
570
					'member' => $this->generateMemberParameter($member)
571
				]
572
			);
573
		}
574
575
		return $event;
576
	}
577
578
	private function parseActivityHeader(IEvent &$event, SharingFrame $frame) {
579