Code Duplication    Length = 41-42 lines in 3 locations

lib/Activity/Provider.php 3 locations

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