Code Duplication    Length = 24-24 lines in 3 locations

mod/gc_mobile_api/models/user.php 2 locations

@@ 575-598 (lines=24) @@
572
		if ($object instanceof ElggUser) {
573
			$event->object = get_user_block($event->object_guid, $lang);
574
			$event->object['type'] = 'user';
575
		} elseif ($object instanceof ElggWire) {
576
			$event->object['type'] = 'wire';
577
			$event->object['wire'] = wire_filter($object->description);
578
579
			$thread_id = $object->wire_thread;
580
			$reshare = $object->getEntitiesFromRelationship(array("relationship" => "reshare", "limit" => 1))[0];
581
582
			$url = "";
583
			if (!empty($reshare)) {
584
				$url = $reshare->getURL();
585
			}
586
587
			$text = "";
588
			if (!empty($reshare->title)) {
589
				$text = $reshare->title;
590
			} elseif (!empty($reshare->name)) {
591
				$text = $reshare->name;
592
			} elseif (!empty($reshare->description)) {
593
				$text = elgg_get_excerpt($reshare->description, 140);
594
			}
595
596
			$event->shareURL = $url;
597
			$event->shareText = gc_explode_translation($text, $lang);
598
		} elseif ($object instanceof ElggGroup) {
599
			$event->object['type'] = 'group';
600
			$event->object['name'] = gc_explode_translation($object->name, $lang);
601
		} elseif ($object instanceof ElggDiscussionReply) {
@@ 813-836 (lines=24) @@
810
		if ($object instanceof ElggUser) {
811
			$event->object = get_user_block($event->object_guid, $lang);
812
			$event->object['type'] = 'user';
813
		} elseif ($object instanceof ElggWire) {
814
			$event->object['type'] = 'wire';
815
			$event->object['wire'] = wire_filter($object->description);
816
817
			$thread_id = $object->wire_thread;
818
			$reshare = $object->getEntitiesFromRelationship(array("relationship" => "reshare", "limit" => 1))[0];
819
820
			$url = "";
821
			if (!empty($reshare)) {
822
				$url = $reshare->getURL();
823
			}
824
825
			$text = "";
826
			if (!empty($reshare->title)) {
827
				$text = $reshare->title;
828
			} elseif (!empty($reshare->name)) {
829
				$text = $reshare->name;
830
			} elseif (!empty($reshare->description)) {
831
				$text = elgg_get_excerpt($reshare->description, 140);
832
			}
833
834
			$event->shareURL = $url;
835
			$event->shareText = gc_explode_translation($text, $lang);
836
		} elseif ($object instanceof ElggGroup) {
837
			$event->object['type'] = 'group';
838
			$event->object['name'] = gc_explode_translation($object->name, $lang);
839
			$event->object['description'] = gc_explode_translation($object->name, $lang);

mod/gc_mobile_api/models/group.php 1 location

@@ 444-467 (lines=24) @@
441
		if ($object instanceof ElggUser) {
442
			$event->object = get_user_block($event->object_guid, $lang);
443
			$event->object['type'] = 'user';
444
		} elseif ($object instanceof ElggWire) {
445
			$event->object['type'] = 'wire';
446
			$event->object['wire'] = wire_filter($object->description);
447
448
			$thread_id = $object->wire_thread;
449
			$reshare = $object->getEntitiesFromRelationship(array("relationship" => "reshare", "limit" => 1))[0];
450
451
			$url = "";
452
			if (!empty($reshare)) {
453
				$url = $reshare->getURL();
454
			}
455
456
			$text = "";
457
			if (!empty($reshare->title)) {
458
				$text = $reshare->title;
459
			} elseif (!empty($reshare->name)) {
460
				$text = $reshare->name;
461
			} elseif (!empty($reshare->description)) {
462
				$text = elgg_get_excerpt($reshare->description, 140);
463
			}
464
465
			$event->shareURL = $url;
466
			$event->shareText = gc_explode_translation($text, $lang);
467
		} elseif ($object instanceof ElggGroup) {
468
			$event->object['type'] = 'group';
469
			$event->object['name'] = gc_explode_translation($object->name, $lang);
470
		} elseif ($object instanceof ElggDiscussionReply) {