Code Duplication    Length = 15-17 lines in 5 locations

packages/device-detection/src/class-user-agent-info.php 5 locations

@@ 777-791 (lines=15) @@
774
		* Detects if the current browser is a Windows Phone 7 device.
775
		* ex: Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; LG; GW910)
776
		*/
777
	static function is_WindowsPhone7() {
778
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
779
			return false;
780
		}
781
782
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
783
784
		if ( false === strpos( $ua, 'windows phone os 7' ) ) {
785
			return false;
786
		} else {
787
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
788
				return false;
789
			} else {
790
				return true;
791
			}
792
		}
793
	}
794
@@ 820-834 (lines=15) @@
817
		* 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
818
		*
819
		*/
820
	static function is_PalmWebOS() {
821
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
822
			return false;
823
		}
824
825
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
826
827
		if ( false === strpos( $ua, 'webos' ) ) {
828
			return false;
829
		} else {
830
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
831
				return false;
832
			} else {
833
				return true;
834
			}
835
		}
836
	}
837
@@ 1008-1023 (lines=16) @@
1005
	/*
1006
		* Detects if the current UA is a MeeGo device (Nokia Smartphone).
1007
		*/
1008
	static function is_MeeGo() {
1009
1010
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
1011
			return false;
1012
		}
1013
1014
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1015
1016
		if ( false === strpos( $ua, 'meego' ) ) {
1017
			return false;
1018
		} else {
1019
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
1020
				return false;
1021
			} else {
1022
				return true;
1023
			}
1024
		}
1025
	}
1026
@@ 1053-1067 (lines=15) @@
1050
	 *
1051
	 * @return boolean true if the browser is Android otherwise false
1052
	 */
1053
	static function is_android() {
1054
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
1055
			return false;
1056
		}
1057
1058
		$agent       = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1059
		$pos_android = strpos( $agent, 'android' );
1060
		if ( $pos_android !== false ) {
1061
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
1062
				return false;
1063
			} else {
1064
				return true;
1065
			}
1066
		} else {
1067
			return false;
1068
		}
1069
	}
1070
@@ 1219-1235 (lines=17) @@
1216
		is_blackbeberry() can be used to check the User Agent for a blackberry device
1217
		Note that opera mini on BB matches this rule.
1218
		*/
1219
	static function is_blackbeberry() {
1220
1221
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
1222
			return false;
1223
		}
1224
1225
		$agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1226
1227
		$pos_blackberry = strpos( $agent, 'blackberry' );
1228
		if ( $pos_blackberry !== false ) {
1229
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) {
1230
				return false;
1231
			} else {
1232
				return true;
1233
			}
1234
		} else {
1235
			return false;
1236
		}
1237
	}
1238