Code Duplication    Length = 41-42 lines in 3 locations

lib/Activity/Provider.php 3 locations

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