Code Duplication    Length = 15-17 lines in 5 locations

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

@@ 910-924 (lines=15) @@
907
	 * Detects if the current browser is a Windows Phone 7 device.
908
	 * ex: Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; LG; GW910)
909
	 */
910
	static function is_WindowsPhone7() {
911
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
912
			return false;
913
		}
914
915
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
916
917
		if ( false === strpos( $ua, 'windows phone os 7' ) ) {
918
			return false;
919
		} else {
920
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
921
				return false;
922
			} else {
923
				return true;
924
			}
925
		}
926
	}
927
@@ 953-967 (lines=15) @@
950
	 * 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
951
	 *
952
	 */
953
	static function is_PalmWebOS() {
954
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
955
			return false;
956
		}
957
958
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
959
960
		if ( false === strpos( $ua, 'webos' ) ) {
961
			return false;
962
		} else {
963
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
964
				return false;
965
			} else {
966
				return true;
967
			}
968
		}
969
	}
970
@@ 1141-1156 (lines=16) @@
1138
	/*
1139
	 * Detects if the current UA is a MeeGo device (Nokia Smartphone).
1140
	 */
1141
	static function is_MeeGo() {
1142
1143
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
1144
			return false;
1145
		}
1146
1147
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1148
1149
		if ( false === strpos( $ua, 'meego' ) ) {
1150
			return false;
1151
		} else {
1152
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
1153
				return false;
1154
			} else {
1155
				return true;
1156
			}
1157
		}
1158
	}
1159
@@ 1186-1200 (lines=15) @@
1183
	 *
1184
	 * @return boolean true if the browser is Android otherwise false
1185
	 */
1186
	static function is_android() {
1187
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
1188
			return false;
1189
		}
1190
1191
		$agent       = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1192
		$pos_android = strpos( $agent, 'android' );
1193
		if ( $pos_android !== false ) {
1194
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
1195
				return false;
1196
			} else {
1197
				return true;
1198
			}
1199
		} else {
1200
			return false;
1201
		}
1202
	}
1203
@@ 1352-1368 (lines=17) @@
1349
	 is_blackbeberry() can be used to check the User Agent for a blackberry device
1350
	 Note that opera mini on BB matches this rule.
1351
	 */
1352
	static function is_blackbeberry() {
1353
1354
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
1355
			return false;
1356
		}
1357
1358
		$agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1359
1360
		$pos_blackberry = strpos( $agent, 'blackberry' );
1361
		if ( $pos_blackberry !== false ) {
1362
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
1363
				return false;
1364
			} else {
1365
				return true;
1366
			}
1367
		} else {
1368
			return false;
1369
		}
1370
	}
1371