Code Duplication    Length = 15-17 lines in 5 locations

class.jetpack-user-agent.php 5 locations

@@ 813-827 (lines=15) @@
810
	 * Detects if the current browser is a Windows Phone 7 device.
811
	 * ex: Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; LG; GW910)
812
	 */
813
	static function is_WindowsPhone7() {
814
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
815
			return false;
816
817
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
818
819
		if ( strpos( $ua, 'windows phone os 7' ) === false ) {
820
			return false;
821
		} else {
822
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
823
	   			return false;
824
	   		else
825
	   			return true;
826
		}
827
	}
828
829
	/*
830
	 * Detects if the current browser is a Windows Phone 8 device.
@@ 853-867 (lines=15) @@
850
	 * 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
851
	 *
852
	 */
853
	static function is_PalmWebOS() {
854
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
855
			return false;
856
857
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
858
859
		if ( strpos( $ua, 'webos' ) === false ) {
860
	   		return false;
861
		} else {
862
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
863
	   			return false;
864
	   		else
865
	   			return true;
866
		}
867
	}
868
869
	/*
870
	 * Detects if the current browser is the HP TouchPad default browser. This excludes phones wt WebOS.
@@ 1023-1038 (lines=16) @@
1020
	/*
1021
	 * Detects if the current UA is a MeeGo device (Nokia Smartphone).
1022
	 */
1023
	static function is_MeeGo() {
1024
1025
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
1026
			return false;
1027
1028
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1029
1030
		if ( strpos( $ua, 'meego' ) === false ) {
1031
	   		return false;
1032
		} else {
1033
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
1034
	   			return false;
1035
	   		else
1036
	   			return true;
1037
		}
1038
	}
1039
1040
1041
	/*
@@ 1063-1077 (lines=15) @@
1060
     * Detects if the current browser is the Native Android browser.
1061
     * @return boolean true if the browser is Android otherwise false
1062
     */
1063
	static function is_android() {
1064
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
1065
			return false;
1066
1067
		$agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1068
		$pos_android = strpos( $agent, 'android' );
1069
		if ( $pos_android !== false ) {
1070
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
1071
	   			return false;
1072
	   		else
1073
	   			return true;
1074
		}
1075
		else
1076
			return false;
1077
	}
1078
1079
1080
	/**
@@ 1200-1216 (lines=17) @@
1197
	 is_blackbeberry() can be used to check the User Agent for a blackberry device
1198
	 Note that opera mini on BB matches this rule.
1199
	 */
1200
	static function is_blackbeberry() {
1201
1202
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
1203
			return false;
1204
1205
		$agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1206
1207
		$pos_blackberry = strpos( $agent, 'blackberry' );
1208
		if ( $pos_blackberry !== false ) {
1209
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
1210
				return false;
1211
			else
1212
				return true;
1213
		} else {
1214
			return false;
1215
		}
1216
	}
1217
1218
	/*
1219
	 is_blackberry_10() can be used to check the User Agent for a BlackBerry 10 device.