Code Duplication    Length = 15-17 lines in 5 locations

class.jetpack-user-agent.php 5 locations

@@ 762-776 (lines=15) @@
759
	 * Detects if the current browser is a Windows Phone 7 device.
760
	 * ex: Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; LG; GW910)
761
	 */
762
	static function is_WindowsPhone7() {
763
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
764
			return false;
765
766
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
767
768
		if ( strpos( $ua, 'windows phone os 7' ) === false ) {
769
			return false;
770
		} else {
771
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
772
	   			return false;
773
	   		else
774
	   			return true;
775
		}
776
	}
777
778
	/*
779
	 * Detects if the current browser is a Windows Phone 8 device.
@@ 802-816 (lines=15) @@
799
	 * 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
800
	 *
801
	 */
802
	static function is_PalmWebOS() {
803
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
804
			return false;
805
806
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
807
808
		if ( strpos( $ua, 'webos' ) === false ) {
809
	   		return false;
810
		} else {
811
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
812
	   			return false;
813
	   		else
814
	   			return true;
815
		}
816
	}
817
818
	/*
819
	 * Detects if the current browser is the HP TouchPad default browser. This excludes phones wt WebOS.
@@ 972-987 (lines=16) @@
969
	/*
970
	 * Detects if the current UA is a MeeGo device (Nokia Smartphone).
971
	 */
972
	static function is_MeeGo() {
973
974
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
975
			return false;
976
977
		$ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
978
979
		if ( strpos( $ua, 'meego' ) === false ) {
980
	   		return false;
981
		} else {
982
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
983
	   			return false;
984
	   		else
985
	   			return true;
986
		}
987
	}
988
989
990
	/*
@@ 1012-1026 (lines=15) @@
1009
     * Detects if the current browser is the Native Android browser.
1010
     * @return boolean true if the browser is Android otherwise false
1011
     */
1012
	static function is_android() {
1013
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
1014
			return false;
1015
1016
		$agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1017
		$pos_android = strpos( $agent, 'android' );
1018
		if ( $pos_android !== false ) {
1019
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
1020
	   			return false;
1021
	   		else
1022
	   			return true;
1023
		}
1024
		else
1025
			return false;
1026
	}
1027
1028
1029
	/**
@@ 1149-1165 (lines=17) @@
1146
	 is_blackbeberry() can be used to check the User Agent for a blackberry device
1147
	 Note that opera mini on BB matches this rule.
1148
	 */
1149
	static function is_blackbeberry() {
1150
1151
		if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
1152
			return false;
1153
1154
		$agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1155
1156
		$pos_blackberry = strpos( $agent, 'blackberry' );
1157
		if ( $pos_blackberry !== false ) {
1158
			if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() )
1159
				return false;
1160
			else
1161
				return true;
1162
		} else {
1163
			return false;
1164
		}
1165
	}
1166
1167
	/*
1168
	 is_blackberry_10() can be used to check the User Agent for a BlackBerry 10 device.