Code Duplication    Length = 41-42 lines in 3 locations

lib/Activity/Provider.php 3 locations

@@ 317-357 (lines=41) @@
314
	 *
315
	 * @return IEvent
316
	 */
317
	private function parseMemberInvited($lang, Circle $circle, Member $member, IEvent $event) {
318
319
		if ($circle->getUser()
320
				   ->getUserId() === $this->activityManager->getCurrentUserId()
321
		) {
322
			$event->setRichSubject(
323
				$this->l10n->t('You invited {member} into {circle}'),
324
				[
325
					'circle' => $this->generateCircleParameter($circle),
326
					'member' => $this->generateMemberParameter($member)
327
				]
328
			);
329
330
		} elseif ($member->getUserId() === $this->activityManager->getCurrentUserId()) {
331
			$event->setRichSubject(
332
				$this->l10n->t('You have been invited into {circle} by {author}'),
333
				[
334
					'author' => $this->generateUserParameter(
335
						$circle->getUser()
336
							   ->getUserId()
337
					),
338
					'circle' => $this->generateCircleParameter($circle)
339
				]
340
			);
341
342
		} else {
343
			$event->setRichSubject(
344
				$this->l10n->t('{member} have been invited into {circle} by {author}'),
345
				[
346
					'author' => $this->generateUserParameter(
347
						$circle->getUser()
348
							   ->getUserId()
349
					),
350
					'circle' => $this->generateCircleParameter($circle),
351
					'member' => $this->generateMemberParameter($member)
352
				]
353
			);
354
		}
355
356
		return $event;
357
	}
358
359
360
	/**
@@ 432-473 (lines=42) @@
429
	 *
430
	 * @return IEvent
431
	 */
432
	private function parseMemberAdd($lang, Circle $circle, Member $member, IEvent $event) {
433
434
		if ($circle->getUser()
435
				   ->getUserId() === $this->activityManager->getCurrentUserId()
436
		) {
437
			$event->setRichSubject(
438
				$this->l10n->t('You added {member} as member to {circle}'),
439
				[
440
					'circle' => $this->generateCircleParameter($circle),
441
					'member' => $this->generateMemberParameter($member)
442
				]
443
			);
444
445
		} elseif ($member->getUserId() === $this->activityManager->getCurrentUserId()) {
446
			$event->setRichSubject(
447
				$this->l10n->t('You were added as member to {circle} by {author}'),
448
				[
449
					'author' => $this->generateUserParameter(
450
						$circle->getUser()
451
							   ->getUserId()
452
					),
453
					'circle' => $this->generateCircleParameter($circle)
454
				]
455
			);
456
457
		} else {
458
			$event->setRichSubject(
459
				$this->l10n->t(
460
					'{member} was added as member to {circle} by {author}'
461
				), [
462
					'author' => $this->generateUserParameter(
463
						$circle->getUser()
464
							   ->getUserId()
465
					),
466
					'circle' => $this->generateCircleParameter($circle),
467
					'member' => $this->generateMemberParameter($member)
468
				]
469
			);
470
		}
471
472
		return $event;
473
	}
474
475
476
	/**
@@ 516-557 (lines=42) @@
513
	 *
514
	 * @return IEvent
515
	 */
516
	private function parseMemberRemove($lang, Circle $circle, Member $member, IEvent $event) {
517
518
		if ($circle->getUser()
519
				   ->getUserId() === $this->activityManager->getCurrentUserId()
520
		) {
521
			$event->setRichSubject(
522
				$this->l10n->t('You removed {member} from {circle}'),
523
				[
524
					'circle' => $this->generateCircleParameter($circle),
525
					'member' => $this->generateMemberParameter($member)
526
				]
527
			);
528
529
		} elseif ($member->getUserId() === $this->activityManager->getCurrentUserId()) {
530
			$event->setRichSubject(
531
				$this->l10n->t('You were removed from {circle} by {author}'),
532
				[
533
					'author' => $this->generateUserParameter(
534
						$circle->getUser()
535
							   ->getUserId()
536
					),
537
					'circle' => $this->generateCircleParameter($circle)
538
				]
539
			);
540
541
		} else {
542
			$event->setRichSubject(
543
				$this->l10n->t(
544
					'{member} was removed from {circle} by {author}'
545
				), [
546
					'author' => $this->generateUserParameter(
547
						$circle->getUser()
548
							   ->getUserId()
549
					),
550
					'circle' => $this->generateCircleParameter($circle),
551
					'member' => $this->generateMemberParameter($member)
552
				]
553
			);
554
		}
555
556
		return $event;
557
	}
558
559
560
	/**