Code Duplication    Length = 35-35 lines in 2 locations

mod/gc_mobile_api/models/user.php 1 location

@@ 610-644 (lines=35) @@
607
			$event->object['type'] = 'file';
608
			$event->object['name'] = gc_explode_translation($object->title, $lang);
609
			$event->object['description'] = gc_explode_translation($object->description, $lang);
610
		} elseif ($object instanceof ElggObject) {
611
			$event->object['type'] = 'discussion-add';
612
613
			if($object->title){
614
				if (strpos($object->title, '"en":') !== false) {
615
					$event->object['name'] = gc_explode_translation($object->title, $lang);
616
				} else {
617
					$event->object['name'] = $object->title;
618
				}
619
			} else if($object->name){
620
				if (strpos($object->name, '"en":') !== false) {
621
					$event->object['name'] = gc_explode_translation($object->name, $lang);
622
				} else {
623
					$event->object['name'] = $object->name;
624
				}
625
			}
626
627
			if (strpos($object->description, '"en":') !== false) {
628
				$event->object['description'] = gc_explode_translation($object->description, $lang);
629
			} else {
630
				$event->object['description'] = $object->description;
631
			}
632
633
			$other = get_entity($event->object_guid);
634
			$parent = get_entity($other->container_guid);
635
			if ($parent instanceof ElggGroup) {
636
				if (!isset($event->object['name'])) {
637
					$event->object['name'] = ($parent->title) ? $parent->title : $parent->name;
638
				}
639
			} else {
640
				if (!isset($event->object['name'])) {
641
					$event->object['name'] = ($parent->title) ? $parent->title : $parent->name;
642
				}
643
			}
644
		} else {
645
			//@TODO handle any unknown events
646
			if (strpos($object->title, '"en":') !== false) {
647
				$event->object['name'] = gc_explode_translation($object->title, $lang);

mod/gc_mobile_api/models/group.php 1 location

@@ 489-523 (lines=35) @@
486
				$event->object['name'] = $object->title;
487
				$event->object['description'] = $object->description;
488
			}
489
		} elseif ($object instanceof ElggObject) {
490
			$event->object['type'] = 'discussion-add';
491
492
			if($object->title){
493
				if (strpos($object->title, '"en":') !== false) {
494
					$event->object['name'] = gc_explode_translation($object->title, $lang);
495
				} else {
496
					$event->object['name'] = $object->title;
497
				}
498
			} else if($object->name){
499
				if (strpos($object->name, '"en":') !== false) {
500
					$event->object['name'] = gc_explode_translation($object->name, $lang);
501
				} else {
502
					$event->object['name'] = $object->name;
503
				}
504
			}
505
506
			if (strpos($object->description, '"en":') !== false) {
507
				$event->object['description'] = gc_explode_translation($object->description, $lang);
508
			} else {
509
				$event->object['description'] = $object->description;
510
			}
511
512
			$other = get_entity($event->object_guid);
513
			$parent = get_entity($other->container_guid);
514
			if ($parent instanceof ElggGroup) {
515
				if (!isset($event->object['name'])) {
516
					$event->object['name'] = ($parent->title) ? $parent->title : $parent->name;
517
				}
518
			} else {
519
				if (!isset($event->object['name'])) {
520
					$event->object['name'] = ($parent->title) ? $parent->title : $parent->name;
521
				}
522
			}
523
		} else {
524
			//@TODO handle any unknown events
525
			if (strpos($object->title, '"en":') !== false) {
526
				$event->object['name'] = gc_explode_translation($object->title, $lang);