Code Duplication    Length = 15-17 lines in 5 locations

class.jetpack-user-agent.php 5 locations

@@ 822-836 (lines=15) @@
819
	 * Detects if the current browser is a Windows Phone 7 device.
820
	 * ex: Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; LG; GW910)
821
	 */
822
	static function is_WindowsPhone7() {
823
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
824
			return false;
825
826
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
827
828
		if ( false === strpos( $ua, 'windows phone os 7' ) ) {
829
			return false;
830
		} else {
831
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
832
	   			return false;
833
	   		else
834
	   			return true;
835
		}
836
	}
837
838
	/*
839
	 * Detects if the current browser is a Windows Phone 8 device.
@@ 862-876 (lines=15) @@
859
	 * 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
860
	 *
861
	 */
862
	static function is_PalmWebOS() {
863
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
864
			return false;
865
866
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
867
868
		if ( false === strpos( $ua, 'webos' ) ) {
869
	   		return false;
870
		} else {
871
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
872
	   			return false;
873
	   		else
874
	   			return true;
875
		}
876
	}
877
878
	/*
879
	 * Detects if the current browser is the HP TouchPad default browser. This excludes phones wt WebOS.
@@ 1032-1047 (lines=16) @@
1029
	/*
1030
	 * Detects if the current UA is a MeeGo device (Nokia Smartphone).
1031
	 */
1032
	static function is_MeeGo() {
1033
1034
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
1035
			return false;
1036
1037
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1038
1039
		if ( false === strpos( $ua, 'meego' ) ) {
1040
	   		return false;
1041
		} else {
1042
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
1043
	   			return false;
1044
	   		else
1045
	   			return true;
1046
		}
1047
	}
1048
1049
1050
	/*
@@ 1072-1086 (lines=15) @@
1069
     * Detects if the current browser is the Native Android browser.
1070
     * @return boolean true if the browser is Android otherwise false
1071
     */
1072
	static function is_android() {
1073
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
1074
			return false;
1075
1076
		$agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1077
		$pos_android = strpos( $agent, 'android' );
1078
		if ( $pos_android !== false ) {
1079
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
1080
	   			return false;
1081
	   		else
1082
	   			return true;
1083
		}
1084
		else
1085
			return false;
1086
	}
1087
1088
1089
	/**
@@ 1209-1225 (lines=17) @@
1206
	 is_blackbeberry() can be used to check the User Agent for a blackberry device
1207
	 Note that opera mini on BB matches this rule.
1208
	 */
1209
	static function is_blackbeberry() {
1210
1211
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
1212
			return false;
1213
1214
		$agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1215
1216
		$pos_blackberry = strpos( $agent, 'blackberry' );
1217
		if ( $pos_blackberry !== false ) {
1218
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
1219
				return false;
1220
			else
1221
				return true;
1222
		} else {
1223
			return false;
1224
		}
1225
	}
1226
1227
	/*
1228
	 is_blackberry_10() can be used to check the User Agent for a BlackBerry 10 device.