Code Duplication    Length = 15-17 lines in 5 locations

class.jetpack-user-agent.php 5 locations

@@ 887-901 (lines=15) @@
884
	 * Detects if the current browser is a Windows Phone 7 device.
885
	 * ex: Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; LG; GW910)
886
	 */
887
	static function is_WindowsPhone7() {
888
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
889
			return false;
890
		}
891
892
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
893
894
		if ( false === strpos( $ua, 'windows phone os 7' ) ) {
895
			return false;
896
		} else {
897
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
898
				return false;
899
			} else {
900
				return true;
901
			}
902
		}
903
	}
904
@@ 930-944 (lines=15) @@
927
	 * 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
928
	 *
929
	 */
930
	static function is_PalmWebOS() {
931
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
932
			return false;
933
		}
934
935
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
936
937
		if ( false === strpos( $ua, 'webos' ) ) {
938
			return false;
939
		} else {
940
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
941
				return false;
942
			} else {
943
				return true;
944
			}
945
		}
946
	}
947
@@ 1118-1133 (lines=16) @@
1115
	/*
1116
	 * Detects if the current UA is a MeeGo device (Nokia Smartphone).
1117
	 */
1118
	static function is_MeeGo() {
1119
1120
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
1121
			return false;
1122
		}
1123
1124
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1125
1126
		if ( false === strpos( $ua, 'meego' ) ) {
1127
			return false;
1128
		} else {
1129
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
1130
				return false;
1131
			} else {
1132
				return true;
1133
			}
1134
		}
1135
	}
1136
@@ 1163-1177 (lines=15) @@
1160
	 *
1161
	 * @return boolean true if the browser is Android otherwise false
1162
	 */
1163
	static function is_android() {
1164
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
1165
			return false;
1166
		}
1167
1168
		$agent       = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1169
		$pos_android = strpos( $agent, 'android' );
1170
		if ( $pos_android !== false ) {
1171
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
1172
				return false;
1173
			} else {
1174
				return true;
1175
			}
1176
		} else {
1177
			return false;
1178
		}
1179
	}
1180
@@ 1329-1345 (lines=17) @@
1326
	 is_blackbeberry() can be used to check the User Agent for a blackberry device
1327
	 Note that opera mini on BB matches this rule.
1328
	 */
1329
	static function is_blackbeberry() {
1330
1331
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
1332
			return false;
1333
		}
1334
1335
		$agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1336
1337
		$pos_blackberry = strpos( $agent, 'blackberry' );
1338
		if ( $pos_blackberry !== false ) {
1339
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
1340
				return false;
1341
			} else {
1342
				return true;
1343
			}
1344
		} else {
1345
			return false;
1346
		}
1347
	}
1348