Code Duplication    Length = 41-42 lines in 3 locations

lib/Activity/Provider.php 3 locations

@@ 244-284 (lines=41) @@
241
	 *
242
	 * @return IEvent
243
	 */
244
	private function parseMemberInvited($lang, Circle $circle, Member $member, IEvent $event) {
245
246
		if ($circle->getUser()
247
				   ->getUserId() === $this->activityManager->getCurrentUserId()
248
		) {
249
			$event->setRichSubject(
250
				$this->l10n->t('You invited {member} into {circle}'),
251
				[
252
					'circle' => $this->generateCircleParameter($circle),
253
					'member' => $this->generateMemberParameter($member)
254
				]
255
			);
256
257
		} elseif ($member->getUserId() === $this->activityManager->getCurrentUserId()) {
258
			$event->setRichSubject(
259
				$this->l10n->t('You have been invited into {circle} by {author}'),
260
				[
261
					'author' => $this->generateUserParameter(
262
						$circle->getUser()
263
							   ->getUserId()
264
					),
265
					'circle' => $this->generateCircleParameter($circle)
266
				]
267
			);
268
269
		} else {
270
			$event->setRichSubject(
271
				$this->l10n->t('{member} have been invited into {circle} by {author}'),
272
				[
273
					'author' => $this->generateUserParameter(
274
						$circle->getUser()
275
							   ->getUserId()
276
					),
277
					'circle' => $this->generateCircleParameter($circle),
278
					'member' => $this->generateMemberParameter($member)
279
				]
280
			);
281
		}
282
283
		return $event;
284
	}
285
286
287
	/**
@@ 359-400 (lines=42) @@
356
	 *
357
	 * @return IEvent
358
	 */
359
	private function parseMemberAdd($lang, Circle $circle, Member $member, IEvent $event) {
360
361
		if ($circle->getUser()
362
				   ->getUserId() === $this->activityManager->getCurrentUserId()
363
		) {
364
			$event->setRichSubject(
365
				$this->l10n->t('You added {member} as member to {circle}'),
366
				[
367
					'circle' => $this->generateCircleParameter($circle),
368
					'member' => $this->generateMemberParameter($member)
369
				]
370
			);
371
372
		} elseif ($member->getUserId() === $this->activityManager->getCurrentUserId()) {
373
			$event->setRichSubject(
374
				$this->l10n->t('You were added as member to {circle} by {author}'),
375
				[
376
					'author' => $this->generateUserParameter(
377
						$circle->getUser()
378
							   ->getUserId()
379
					),
380
					'circle' => $this->generateCircleParameter($circle)
381
				]
382
			);
383
384
		} else {
385
			$event->setRichSubject(
386
				$this->l10n->t(
387
					'{member} was added as member to {circle} by {author}'
388
				), [
389
					'author' => $this->generateUserParameter(
390
						$circle->getUser()
391
							   ->getUserId()
392
					),
393
					'circle' => $this->generateCircleParameter($circle),
394
					'member' => $this->generateMemberParameter($member)
395
				]
396
			);
397
		}
398
399
		return $event;
400
	}
401
402
403
	/**
@@ 443-484 (lines=42) @@
440
	 *
441
	 * @return IEvent
442
	 */
443
	private function parseMemberRemove($lang, Circle $circle, Member $member, IEvent $event) {
444
445
		if ($circle->getUser()
446
				   ->getUserId() === $this->activityManager->getCurrentUserId()
447
		) {
448
			$event->setRichSubject(
449
				$this->l10n->t('You removed {member} from {circle}'),
450
				[
451
					'circle' => $this->generateCircleParameter($circle),
452
					'member' => $this->generateMemberParameter($member)
453
				]
454
			);
455
456
		} elseif ($member->getUserId() === $this->activityManager->getCurrentUserId()) {
457
			$event->setRichSubject(
458
				$this->l10n->t('You were removed from {circle} by {author}'),
459
				[
460
					'author' => $this->generateUserParameter(
461
						$circle->getUser()
462
							   ->getUserId()
463
					),
464
					'circle' => $this->generateCircleParameter($circle)
465
				]
466
			);
467
468
		} else {
469
			$event->setRichSubject(
470
				$this->l10n->t(
471
					'{member} was removed from {circle} by {author}'
472
				), [
473
					'author' => $this->generateUserParameter(
474
						$circle->getUser()
475
							   ->getUserId()
476
					),
477
					'circle' => $this->generateCircleParameter($circle),
478
					'member' => $this->generateMemberParameter($member)
479
				]
480
			);
481
		}
482
483
		return $event;
484
	}
485
486
487
	/**