Code Duplication    Length = 15-17 lines in 5 locations

packages/device-detection/src/class-device-detection.php 5 locations

@@ 970-984 (lines=15) @@
967
	 * Detects if the current browser is a Windows Phone 7 device.
968
	 * ex: Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; LG; GW910)
969
	 */
970
	static function is_WindowsPhone7() {
971
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
972
			return false;
973
		}
974
975
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
976
977
		if ( false === strpos( $ua, 'windows phone os 7' ) ) {
978
			return false;
979
		} else {
980
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
981
				return false;
982
			} else {
983
				return true;
984
			}
985
		}
986
	}
987
@@ 1013-1027 (lines=15) @@
1010
	 * 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
1011
	 *
1012
	 */
1013
	static function is_PalmWebOS() {
1014
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
1015
			return false;
1016
		}
1017
1018
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1019
1020
		if ( false === strpos( $ua, 'webos' ) ) {
1021
			return false;
1022
		} else {
1023
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
1024
				return false;
1025
			} else {
1026
				return true;
1027
			}
1028
		}
1029
	}
1030
@@ 1201-1216 (lines=16) @@
1198
	/*
1199
	 * Detects if the current UA is a MeeGo device (Nokia Smartphone).
1200
	 */
1201
	static function is_MeeGo() {
1202
1203
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
1204
			return false;
1205
		}
1206
1207
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1208
1209
		if ( false === strpos( $ua, 'meego' ) ) {
1210
			return false;
1211
		} else {
1212
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
1213
				return false;
1214
			} else {
1215
				return true;
1216
			}
1217
		}
1218
	}
1219
@@ 1246-1260 (lines=15) @@
1243
	 *
1244
	 * @return boolean true if the browser is Android otherwise false
1245
	 */
1246
	static function is_android() {
1247
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
1248
			return false;
1249
		}
1250
1251
		$agent       = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1252
		$pos_android = strpos( $agent, 'android' );
1253
		if ( $pos_android !== false ) {
1254
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
1255
				return false;
1256
			} else {
1257
				return true;
1258
			}
1259
		} else {
1260
			return false;
1261
		}
1262
	}
1263
@@ 1412-1428 (lines=17) @@
1409
	 is_blackbeberry() can be used to check the User Agent for a blackberry device
1410
	 Note that opera mini on BB matches this rule.
1411
	 */
1412
	static function is_blackbeberry() {
1413
1414
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
1415
			return false;
1416
		}
1417
1418
		$agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1419
1420
		$pos_blackberry = strpos( $agent, 'blackberry' );
1421
		if ( $pos_blackberry !== false ) {
1422
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
1423
				return false;
1424
			} else {
1425
				return true;
1426
			}
1427
		} else {
1428
			return false;
1429
		}
1430
	}
1431