Code Duplication    Length = 15-17 lines in 5 locations

class.jetpack-user-agent.php 5 locations

@@ 817-831 (lines=15) @@
814
	 * Detects if the current browser is a Windows Phone 7 device.
815
	 * ex: Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; LG; GW910)
816
	 */
817
	static function is_WindowsPhone7() {
818
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
819
			return false;
820
821
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
822
823
		if ( strpos( $ua, 'windows phone os 7' ) === false ) {
824
			return false;
825
		} else {
826
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
827
	   			return false;
828
	   		else
829
	   			return true;
830
		}
831
	}
832
833
	/*
834
	 * Detects if the current browser is a Windows Phone 8 device.
@@ 857-871 (lines=15) @@
854
	 * ex2: Mozilla/5.0 (webOS/1.4.0; U; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Version/1.0 Safari/532.2 Pixi/1.1
855
	 *
856
	 */
857
	static function is_PalmWebOS() {
858
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
859
			return false;
860
861
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
862
863
		if ( strpos( $ua, 'webos' ) === false ) {
864
	   		return false;
865
		} else {
866
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
867
	   			return false;
868
	   		else
869
	   			return true;
870
		}
871
	}
872
873
	/*
874
	 * Detects if the current browser is the HP TouchPad default browser. This excludes phones wt WebOS.
@@ 1027-1042 (lines=16) @@
1024
	/*
1025
	 * Detects if the current UA is a MeeGo device (Nokia Smartphone).
1026
	 */
1027
	static function is_MeeGo() {
1028
1029
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
1030
			return false;
1031
1032
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1033
1034
		if ( strpos( $ua, 'meego' ) === false ) {
1035
	   		return false;
1036
		} else {
1037
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
1038
	   			return false;
1039
	   		else
1040
	   			return true;
1041
		}
1042
	}
1043
1044
1045
	/*
@@ 1067-1081 (lines=15) @@
1064
     * Detects if the current browser is the Native Android browser.
1065
     * @return boolean true if the browser is Android otherwise false
1066
     */
1067
	static function is_android() {
1068
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
1069
			return false;
1070
1071
		$agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1072
		$pos_android = strpos( $agent, 'android' );
1073
		if ( $pos_android !== false ) {
1074
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
1075
	   			return false;
1076
	   		else
1077
	   			return true;
1078
		}
1079
		else
1080
			return false;
1081
	}
1082
1083
1084
	/**
@@ 1204-1220 (lines=17) @@
1201
	 is_blackbeberry() can be used to check the User Agent for a blackberry device
1202
	 Note that opera mini on BB matches this rule.
1203
	 */
1204
	static function is_blackbeberry() {
1205
1206
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
1207
			return false;
1208
1209
		$agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1210
1211
		$pos_blackberry = strpos( $agent, 'blackberry' );
1212
		if ( $pos_blackberry !== false ) {
1213
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
1214
				return false;
1215
			else
1216
				return true;
1217
		} else {
1218
			return false;
1219
		}
1220
	}
1221
1222
	/*
1223
	 is_blackberry_10() can be used to check the User Agent for a BlackBerry 10 device.