Code Duplication    Length = 26-27 lines in 3 locations

mod/wet4/start.php 3 locations

@@ 700-726 (lines=27) @@
697
	$entContext = $entity->getType();
698
699
	//check if entity is an object or group
700
	if ($entContext == 'object') {
701
702
		//find subtype
703
		$contentType = $entity->getSubtype();
704
		//convert subtype into plain language
705
		$entContext = proper_subtypes($contentType);//$entity->getSubtype();
706
707
		//check to see if entity is one f the entities with a title
708
		if (!in_array($entity->getSubtype(), array('comment', 'discussion_reply', 'thewire'))) {
709
			if ($entity->title3) {
710
				$entName = gc_explode_translation($entity->title3, $lang);
711
			} else {
712
				$entName = $entity->title;
713
			}
714
		} else { //if not get owner instead of name
715
716
			$entName = $entity->getOwnerEntity()->name;
717
		}
718
	} elseif ($entContext == 'group') {
719
		$contentType = 'group';
720
		$entContext = elgg_echo('group');
721
		if ($entity->title3) {
722
			$entName = gc_explode_translation($entity->title3, $lang);
723
		} else {
724
			$entName = $entity->name;
725
		}
726
	}
727
728
	if ($entity->canAnnotate(0, 'likes')) {
729
		$hasLiked = \Elgg\Likes\DataService::instance()->currentUserLikesEntity($entity->guid);
@@ 884-910 (lines=27) @@
881
	$entContext = $entity->getType();
882
883
	//check if entity is an object or group
884
	if ($entContext == 'object') {
885
886
		//find subtype
887
		$contentType = $entity->getSubtype();
888
		//convert subtype into plain language
889
		$entContext = proper_subtypes($contentType);
890
891
		//check to see if entity is one f the entities with a title
892
		if (!in_array($entity->getSubtype(), array('comment', 'discussion_reply', 'thewire', 'answer'))) {
893
			if ($entity->title3) {
894
				$entName = gc_explode_translation($entity->title3, $lang);
895
			} else {
896
				$entName = $entity->title;
897
			}
898
		} else { //if not get owner instead of name
899
900
			$entName = $entity->getOwnerEntity()->name;
901
		}
902
	} elseif ($entContext == 'group') {
903
		$contentType = 'group';
904
		$entContext = elgg_echo('group');
905
		if ($entity->title3) {
906
			$entName = gc_explode_translation($entity->title3, $lang);
907
		} else {
908
			$entName = $entity->name;
909
		}
910
	}
911
912
	//pass type and entiey/owner name to function to return array of text
913
	$hiddenText = generate_hidden_text($contentType, $entName);
@@ 1252-1277 (lines=26) @@
1249
1250
		$entContext = $object->getType();
1251
		//check if entity is an object or group
1252
		if ($entContext == 'object') {
1253
1254
			//find subtype
1255
			$contentType = $object->getSubtype();
1256
			//convert subtype into plain language
1257
			$entContext = proper_subtypes($contentType);
1258
1259
			//check to see if entity is one f the entities with a title
1260
			if (!in_array($object->getSubtype(), array('comment', 'discussion_reply', 'thewire', 'answer'))) {
1261
				if ($object->title3) {
1262
					$entName = gc_explode_translation($object->title3, $lang);
1263
				} else {
1264
					$entName = gc_explode_translation($object->title, $lang);
1265
				}
1266
			} else { //if not get owner instead of name
1267
				$entName = $object->getOwnerEntity()->name;
1268
			}
1269
		} elseif ($entContext == 'group') {
1270
			$contentType = 'group';
1271
			$entContext = elgg_echo('group');
1272
			if ($object->title3) {
1273
				$entName = gc_explode_translation($object->title3, $lang);
1274
			} else {
1275
				$entName = $object->name;
1276
			}
1277
		}
1278
1279
		//pass type and entiey/owner name to function to return array of text
1280
		$hiddenText = generate_hidden_text($contentType, $entName);