Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like User_Agent_Info often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use User_Agent_Info, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 19 | class User_Agent_Info { |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Provided or fetched User-Agent string. |
||
| 23 | * |
||
| 24 | * @var string |
||
| 25 | */ |
||
| 26 | public $useragent; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * A device group matched user agent, e.g. 'iphone'. |
||
| 30 | * |
||
| 31 | * @var string |
||
| 32 | */ |
||
| 33 | public $matched_agent; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Stores whether is the iPhone tier of devices. |
||
| 37 | * |
||
| 38 | * @var bool |
||
| 39 | */ |
||
| 40 | public $isTierIphone; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Stores whether the device can probably support Rich CSS, but JavaScript (jQuery) support is not assumed. |
||
| 44 | * |
||
| 45 | * @var bool |
||
| 46 | */ |
||
| 47 | public $isTierRichCss; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Stores whether it is another mobile device, which cannot be assumed to support CSS or JS (eg, older BlackBerry, RAZR) |
||
| 51 | * |
||
| 52 | * @var bool |
||
| 53 | */ |
||
| 54 | public $isTierGenericMobile; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Stores the device platform name |
||
| 58 | * |
||
| 59 | * @var null|string |
||
| 60 | */ |
||
| 61 | private $platform = null; |
||
| 62 | const PLATFORM_WINDOWS = 'windows'; |
||
| 63 | const PLATFORM_IPHONE = 'iphone'; |
||
| 64 | const PLATFORM_IPOD = 'ipod'; |
||
| 65 | const PLATFORM_IPAD = 'ipad'; |
||
| 66 | const PLATFORM_BLACKBERRY = 'blackberry'; |
||
| 67 | const PLATFORM_BLACKBERRY_10 = 'blackberry_10'; |
||
| 68 | const PLATFORM_SYMBIAN = 'symbian_series60'; |
||
| 69 | const PLATFORM_SYMBIAN_S40 = 'symbian_series40'; |
||
| 70 | const PLATFORM_J2ME_MIDP = 'j2me_midp'; |
||
| 71 | const PLATFORM_ANDROID = 'android'; |
||
| 72 | const PLATFORM_ANDROID_TABLET = 'android_tablet'; |
||
| 73 | const PLATFORM_FIREFOX_OS = 'firefoxOS'; |
||
| 74 | |||
| 75 | /** |
||
| 76 | * A list of dumb-phone user agent parts. |
||
| 77 | * |
||
| 78 | * @var array |
||
| 79 | */ |
||
| 80 | public $dumb_agents = array( |
||
| 81 | 'nokia', |
||
| 82 | 'blackberry', |
||
| 83 | 'philips', |
||
| 84 | 'samsung', |
||
| 85 | 'sanyo', |
||
| 86 | 'sony', |
||
| 87 | 'panasonic', |
||
| 88 | 'webos', |
||
| 89 | 'ericsson', |
||
| 90 | 'alcatel', |
||
| 91 | 'palm', |
||
| 92 | 'windows ce', |
||
| 93 | 'opera mini', |
||
| 94 | 'series60', |
||
| 95 | 'series40', |
||
| 96 | 'au-mic,', |
||
| 97 | 'audiovox', |
||
| 98 | 'avantgo', |
||
| 99 | 'blazer', |
||
| 100 | 'danger', |
||
| 101 | 'docomo', |
||
| 102 | 'epoc', |
||
| 103 | 'ericy', |
||
| 104 | 'i-mode', |
||
| 105 | 'ipaq', |
||
| 106 | 'midp-', |
||
| 107 | 'mot-', |
||
| 108 | 'netfront', |
||
| 109 | 'nitro', |
||
| 110 | 'palmsource', |
||
| 111 | 'pocketpc', |
||
| 112 | 'portalmmm', |
||
| 113 | 'rover', |
||
| 114 | 'sie-', |
||
| 115 | 'symbian', |
||
| 116 | 'cldc-', |
||
| 117 | 'j2me', |
||
| 118 | 'smartphone', |
||
| 119 | 'up.browser', |
||
| 120 | 'up.link', |
||
| 121 | 'up.link', |
||
| 122 | 'vodafone/', |
||
| 123 | 'wap1.', |
||
| 124 | 'wap2.', |
||
| 125 | 'mobile', |
||
| 126 | 'googlebot-mobile', |
||
| 127 | ); |
||
| 128 | |||
| 129 | /** |
||
| 130 | * The constructor. |
||
| 131 | * |
||
| 132 | * @param string $ua (Optional) User agent. |
||
| 133 | */ |
||
| 134 | public function __construct( $ua = '' ) { |
||
| 143 | |||
| 144 | /** |
||
| 145 | * This method detects the mobile User Agent name. |
||
| 146 | * |
||
| 147 | * @return string The matched User Agent name, false otherwise. |
||
| 148 | */ |
||
| 149 | public function get_mobile_user_agent_name() { |
||
| 220 | |||
| 221 | /** |
||
| 222 | * This method detects the mobile device's platform. All return strings are from the class constants. |
||
| 223 | * Note that this function returns the platform name, not the UA name/type. You should use a different function |
||
| 224 | * if you need to test the UA capabilites. |
||
| 225 | * |
||
| 226 | * @return string Name of the platform, false otherwise. |
||
| 227 | */ |
||
| 228 | public function get_platform() { |
||
| 271 | |||
| 272 | /** |
||
| 273 | * This method detects for UA which can display iPhone-optimized web content. |
||
| 274 | * Includes iPhone, iPod Touch, Android, WebOS, Fennec (Firefox mobile), etc. |
||
| 275 | */ |
||
| 276 | public function isTierIphone() { |
||
| 365 | |||
| 366 | /** |
||
| 367 | * This method detects for UA which are likely to be capable |
||
| 368 | * but may not necessarily support JavaScript. |
||
| 369 | * Excludes all iPhone Tier UA. |
||
| 370 | */ |
||
| 371 | public function isTierRichCss() { |
||
| 408 | |||
| 409 | /** |
||
| 410 | * Detects if the user is using a tablet. |
||
| 411 | * props Corey Gilmore, BGR.com |
||
| 412 | * |
||
| 413 | * @return bool |
||
| 414 | */ |
||
| 415 | public function is_tablet() { |
||
| 425 | |||
| 426 | /** |
||
| 427 | * Detects if the current UA is the default iPhone or iPod Touch Browser. |
||
| 428 | * |
||
| 429 | * DEPRECATED: use is_iphone_or_ipod |
||
| 430 | */ |
||
| 431 | public function is_iphoneOrIpod() { |
||
| 447 | |||
| 448 | /** |
||
| 449 | * Detects if the current UA is iPhone Mobile Safari or another iPhone or iPod Touch Browser. |
||
| 450 | * |
||
| 451 | * They type can check for any iPhone, an iPhone using Safari, or an iPhone using something other than Safari. |
||
| 452 | * |
||
| 453 | * Note: If you want to check for Opera mini, Opera mobile or Firefox mobile (or any 3rd party iPhone browser), |
||
| 454 | * you should put the check condition before the check for 'iphone-any' or 'iphone-not-safari'. |
||
| 455 | * Otherwise those browsers will be 'catched' by the iphone string. |
||
| 456 | * |
||
| 457 | * @param string $type Type of iPhone detection. |
||
| 458 | */ |
||
| 459 | public static function is_iphone_or_ipod( $type = 'iphone-any' ) { |
||
| 476 | |||
| 477 | /** |
||
| 478 | * Detects if the current UA is Chrome for iOS |
||
| 479 | * |
||
| 480 | * The User-Agent string in Chrome for iOS is the same as the Mobile Safari User-Agent, with CriOS/<ChromeRevision> instead of Version/<VersionNum>. |
||
| 481 | * - Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3 |
||
| 482 | */ |
||
| 483 | public static function is_chrome_for_iOS() { |
||
| 500 | |||
| 501 | /** |
||
| 502 | * Detects if the current UA is Twitter for iPhone |
||
| 503 | * |
||
| 504 | * Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_5 like Mac OS X; nb-no) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile/8L1 Twitter for iPhone |
||
| 505 | * Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B206 Twitter for iPhone |
||
| 506 | */ |
||
| 507 | public static function is_twitter_for_iphone() { |
||
| 524 | |||
| 525 | /** |
||
| 526 | * Detects if the current UA is Twitter for iPad |
||
| 527 | * |
||
| 528 | * Old version 4.X - Mozilla/5.0 (iPad; U; CPU OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile/8L1 Twitter for iPad |
||
| 529 | * Ver 5.0 or Higher - Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B206 Twitter for iPhone |
||
| 530 | */ |
||
| 531 | public static function is_twitter_for_ipad() { |
||
| 546 | |||
| 547 | /** |
||
| 548 | * Detects if the current UA is Facebook for iPhone |
||
| 549 | * - Facebook 4020.0 (iPhone; iPhone OS 5.0.1; fr_FR) |
||
| 550 | * - Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_0 like Mac OS X; en_US) AppleWebKit (KHTML, like Gecko) Mobile [FBAN/FBForIPhone;FBAV/4.0.2;FBBV/4020.0;FBDV/iPhone3,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/5.0;FBSS/2; FBCR/O2;FBID/phone;FBLC/en_US;FBSF/2.0] |
||
| 551 | * - Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B206 [FBAN/FBIOS;FBAV/5.0;FBBV/47423;FBDV/iPhone3,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/5.1.1;FBSS/2; FBCR/3ITA;FBID/phone;FBLC/en_US] |
||
| 552 | */ |
||
| 553 | public static function is_facebook_for_iphone() { |
||
| 574 | |||
| 575 | /** |
||
| 576 | * Detects if the current UA is Facebook for iPad |
||
| 577 | * - Facebook 4020.0 (iPad; iPhone OS 5.0.1; en_US) |
||
| 578 | * - Mozilla/5.0 (iPad; U; CPU iPhone OS 5_0 like Mac OS X; en_US) AppleWebKit (KHTML, like Gecko) Mobile [FBAN/FBForIPhone;FBAV/4.0.2;FBBV/4020.0;FBDV/iPad2,1;FBMD/iPad;FBSN/iPhone OS;FBSV/5.0;FBSS/1; FBCR/;FBID/tablet;FBLC/en_US;FBSF/1.0] |
||
| 579 | * - Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10A403 [FBAN/FBIOS;FBAV/5.0;FBBV/47423;FBDV/iPad2,1;FBMD/iPad;FBSN/iPhone OS;FBSV/6.0;FBSS/1; FBCR/;FBID/tablet;FBLC/en_US] |
||
| 580 | */ |
||
| 581 | View Code Duplication | public static function is_facebook_for_ipad() { |
|
| 598 | |||
| 599 | /** |
||
| 600 | * Detects if the current UA is WordPress for iOS |
||
| 601 | */ |
||
| 602 | public static function is_wordpress_for_ios() { |
||
| 614 | |||
| 615 | /** |
||
| 616 | * Detects if the current device is an iPad. |
||
| 617 | * They type can check for any iPad, an iPad using Safari, or an iPad using something other than Safari. |
||
| 618 | * |
||
| 619 | * Note: If you want to check for Opera mini, Opera mobile or Firefox mobile (or any 3rd party iPad browser), |
||
| 620 | * you should put the check condition before the check for 'iphone-any' or 'iphone-not-safari'. |
||
| 621 | * Otherwise those browsers will be 'catched' by the ipad string. |
||
| 622 | * |
||
| 623 | * @param string $type iPad type. |
||
| 624 | */ |
||
| 625 | public static function is_ipad( $type = 'ipad-any' ) { |
||
| 644 | |||
| 645 | /** |
||
| 646 | * Detects if the current browser is Firefox Mobile (Fennec) |
||
| 647 | * |
||
| 648 | * See http://www.useragentstring.com/pages/Fennec/ |
||
| 649 | * Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.1.1) Gecko/20110415 Firefox/4.0.2pre Fennec/4.0.1 |
||
| 650 | * Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1b2pre) Gecko/20081015 Fennec/1.0a1 |
||
| 651 | */ |
||
| 652 | public static function is_firefox_mobile() { |
||
| 666 | |||
| 667 | /** |
||
| 668 | * Detects if the current browser is Firefox for desktop |
||
| 669 | * |
||
| 670 | * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox |
||
| 671 | * Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion |
||
| 672 | * The platform section will include 'Mobile' for phones and 'Tablet' for tablets. |
||
| 673 | */ |
||
| 674 | View Code Duplication | public static function is_firefox_desktop() { |
|
| 688 | |||
| 689 | /** |
||
| 690 | * Detects if the current browser is FirefoxOS Native browser |
||
| 691 | * |
||
| 692 | * Mozilla/5.0 (Mobile; rv:14.0) Gecko/14.0 Firefox/14.0 |
||
| 693 | */ |
||
| 694 | View Code Duplication | public static function is_firefox_os() { |
|
| 708 | |||
| 709 | /** |
||
| 710 | * Detects if the current browser is Opera Mobile |
||
| 711 | * |
||
| 712 | * What is the difference between Opera Mobile and Opera Mini? |
||
| 713 | * - Opera Mobile is a full Internet browser for mobile devices. |
||
| 714 | * - Opera Mini always uses a transcoder to convert the page for a small display. |
||
| 715 | * (it uses Opera advanced server compression technology to compress web content before it gets to a device. |
||
| 716 | * The rendering engine is on Opera's server.) |
||
| 717 | * |
||
| 718 | * Opera/9.80 (Windows NT 6.1; Opera Mobi/14316; U; en) Presto/2.7.81 Version/11.00" |
||
| 719 | * Opera/9.50 (Nintendo DSi; Opera/507; U; en-US) |
||
| 720 | */ |
||
| 721 | View Code Duplication | public static function is_opera_mobile() { |
|
| 736 | |||
| 737 | /** |
||
| 738 | * Detects if the current browser is Opera Mini |
||
| 739 | * |
||
| 740 | * Opera/8.01 (J2ME/MIDP; Opera Mini/3.0.6306/1528; en; U; ssr) |
||
| 741 | * Opera/9.80 (Android;Opera Mini/6.0.24212/24.746 U;en) Presto/2.5.25 Version/10.5454 |
||
| 742 | * Opera/9.80 (iPhone; Opera Mini/5.0.019802/18.738; U; en) Presto/2.4.15 |
||
| 743 | * Opera/9.80 (J2ME/iPhone;Opera Mini/5.0.019802/886; U; ja) Presto/2.4.15 |
||
| 744 | * Opera/9.80 (J2ME/iPhone;Opera Mini/5.0.019802/886; U; ja) Presto/2.4.15 |
||
| 745 | * Opera/9.80 (Series 60; Opera Mini/5.1.22783/23.334; U; en) Presto/2.5.25 Version/10.54 |
||
| 746 | * Opera/9.80 (BlackBerry; Opera Mini/5.1.22303/22.387; U; en) Presto/2.5.25 Version/10.54 |
||
| 747 | */ |
||
| 748 | public static function is_opera_mini() { |
||
| 761 | |||
| 762 | /** |
||
| 763 | * Detects if the current browser is Opera Mini, but not on a smart device OS(Android, iOS, etc) |
||
| 764 | * Used to send users on dumb devices to m.wor |
||
| 765 | */ |
||
| 766 | public static function is_opera_mini_dumb() { |
||
| 783 | |||
| 784 | /** |
||
| 785 | * Detects if the current browser is Opera Mobile or Mini. |
||
| 786 | * DEPRECATED: use is_opera_mobile or is_opera_mini |
||
| 787 | * |
||
| 788 | * Opera Mini 5 Beta: Opera/9.80 (J2ME/MIDP; Opera Mini/5.0.15650/756; U; en) Presto/2.2.0 |
||
| 789 | * Opera Mini 8: Opera/8.01 (J2ME/MIDP; Opera Mini/3.0.6306/1528; en; U; ssr) |
||
| 790 | */ |
||
| 791 | public static function is_OperaMobile() { |
||
| 810 | |||
| 811 | /** |
||
| 812 | * Detects if the current browser is a Windows Phone 7 device. |
||
| 813 | * ex: Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; LG; GW910) |
||
| 814 | */ |
||
| 815 | View Code Duplication | public static function is_WindowsPhone7() { |
|
| 832 | |||
| 833 | /** |
||
| 834 | * Detects if the current browser is a Windows Phone 8 device. |
||
| 835 | * ex: Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; ARM; Touch; IEMobile/10.0; <Manufacturer>; <Device> [;<Operator>]) |
||
| 836 | */ |
||
| 837 | public static function is_windows_phone_8() { |
||
| 849 | |||
| 850 | /** |
||
| 851 | * Detects if the current browser is on a Palm device running the new WebOS. This EXCLUDES TouchPad. |
||
| 852 | * |
||
| 853 | * Ex1: Mozilla/5.0 (webOS/1.4.0; U; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Version/1.0 Safari/532.2 Pre/1.1 |
||
| 854 | * 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 |
||
| 855 | */ |
||
| 856 | View Code Duplication | public static function is_PalmWebOS() { |
|
| 873 | |||
| 874 | /** |
||
| 875 | * Detects if the current browser is the HP TouchPad default browser. This excludes phones wt WebOS. |
||
| 876 | * |
||
| 877 | * TouchPad Emulator: Mozilla/5.0 (hp-desktop; Linux; hpwOS/2.0; U; it-IT) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/233.70 Safari/534.6 Desktop/1.0 |
||
| 878 | * TouchPad: Mozilla/5.0 (hp-tablet; Linux; hpwOS/3.0.0; U; en-US) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/233.70 Safari/534.6 TouchPad/1.0 |
||
| 879 | */ |
||
| 880 | public static function is_TouchPad() { |
||
| 896 | |||
| 897 | /** |
||
| 898 | * Detects if the current browser is the Series 60 Open Source Browser. |
||
| 899 | * |
||
| 900 | * OSS Browser 3.2 on E75: Mozilla/5.0 (SymbianOS/9.3; U; Series60/3.2 NokiaE75-1/110.48.125 Profile/MIDP-2.1 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413 |
||
| 901 | * |
||
| 902 | * 7.0 Browser (Nokia 5800 XpressMusic (v21.0.025)) : Mozilla/5.0 (SymbianOS/9.4; U; Series60/5.0 Nokia5800d-1/21.0.025; Profile/MIDP-2.1 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413 |
||
| 903 | * |
||
| 904 | * Browser 7.1 (Nokia N97 (v12.0.024)) : Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 NokiaN97-1/12.0.024; Profile/MIDP-2.1 Configuration/CLDC-1.1; en-us) AppleWebKit/525 (KHTML, like Gecko) BrowserNG/7.1.12344 |
||
| 905 | */ |
||
| 906 | public static function is_S60_OSSBrowser() { |
||
| 933 | |||
| 934 | /** |
||
| 935 | * Detects if the device platform is the Symbian Series 60. |
||
| 936 | */ |
||
| 937 | public static function is_symbian_platform() { |
||
| 965 | |||
| 966 | /** |
||
| 967 | * Detects if the device platform is the Symbian Series 40. |
||
| 968 | * Nokia Browser for Series 40 is a proxy based browser, previously known as Ovi Browser. |
||
| 969 | * This browser will report 'NokiaBrowser' in the header, however some older version will also report 'OviBrowser'. |
||
| 970 | */ |
||
| 971 | View Code Duplication | public static function is_symbian_s40_platform() { |
|
| 987 | |||
| 988 | /** |
||
| 989 | * Returns if the device belongs to J2ME capable family. |
||
| 990 | * |
||
| 991 | * @return bool |
||
| 992 | */ |
||
| 993 | View Code Duplication | public static function is_J2ME_platform() { |
|
| 1008 | |||
| 1009 | /** |
||
| 1010 | * Detects if the current UA is on one of the Maemo-based Nokia Internet Tablets. |
||
| 1011 | */ |
||
| 1012 | public static function is_MaemoTablet() { |
||
| 1036 | |||
| 1037 | /** |
||
| 1038 | * Detects if the current UA is a MeeGo device (Nokia Smartphone). |
||
| 1039 | */ |
||
| 1040 | View Code Duplication | public static function is_MeeGo() { |
|
| 1058 | |||
| 1059 | /** |
||
| 1060 | * The is_webkit() method can be used to check the User Agent for an webkit generic browser. |
||
| 1061 | */ |
||
| 1062 | View Code Duplication | public static function is_webkit() { |
|
| 1078 | |||
| 1079 | /** |
||
| 1080 | * Detects if the current browser is the Native Android browser. |
||
| 1081 | * |
||
| 1082 | * @return boolean true if the browser is Android otherwise false |
||
| 1083 | */ |
||
| 1084 | View Code Duplication | public static function is_android() { |
|
| 1101 | |||
| 1102 | /** |
||
| 1103 | * Detects if the current browser is the Native Android Tablet browser. |
||
| 1104 | * Assumes 'Android' should be in the user agent, but not 'mobile' |
||
| 1105 | * |
||
| 1106 | * @return boolean true if the browser is Android and not 'mobile' otherwise false |
||
| 1107 | */ |
||
| 1108 | public static function is_android_tablet() { |
||
| 1129 | |||
| 1130 | /** |
||
| 1131 | * Detects if the current browser is the Kindle Fire Native browser. |
||
| 1132 | * |
||
| 1133 | * Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-84) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true |
||
| 1134 | * Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-84) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=false |
||
| 1135 | * |
||
| 1136 | * @return boolean true if the browser is Kindle Fire Native browser otherwise false |
||
| 1137 | */ |
||
| 1138 | public static function is_kindle_fire() { |
||
| 1152 | |||
| 1153 | /** |
||
| 1154 | * Detects if the current browser is the Kindle Touch Native browser |
||
| 1155 | * |
||
| 1156 | * Mozilla/5.0 (X11; U; Linux armv7l like Android; en-us) AppleWebKit/531.2+ (KHTML, like Gecko) Version/5.0 Safari/533.2+ Kindle/3.0+ |
||
| 1157 | * |
||
| 1158 | * @return boolean true if the browser is Kindle monochrome Native browser otherwise false |
||
| 1159 | */ |
||
| 1160 | View Code Duplication | public static function is_kindle_touch() { |
|
| 1172 | |||
| 1173 | /** |
||
| 1174 | * Detect if user agent is the WordPress.com Windows 8 app (used ONLY on the custom oauth stylesheet) |
||
| 1175 | */ |
||
| 1176 | View Code Duplication | public static function is_windows8_auth() { |
|
| 1189 | |||
| 1190 | /** |
||
| 1191 | * Detect if user agent is the WordPress.com Windows 8 app. |
||
| 1192 | */ |
||
| 1193 | View Code Duplication | public static function is_wordpress_for_win8() { |
|
| 1206 | |||
| 1207 | /** |
||
| 1208 | * Detect if user agent is the WordPress.com Desktop app. |
||
| 1209 | */ |
||
| 1210 | View Code Duplication | public static function is_wordpress_desktop_app() { |
|
| 1223 | |||
| 1224 | /** |
||
| 1225 | * The is_blackberry_tablet() method can be used to check the User Agent for a RIM blackberry tablet. |
||
| 1226 | * The user agent of the BlackBerry® Tablet OS follows a format similar to the following: |
||
| 1227 | * Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWebKit/534.8+ (KHTML, like Gecko) Version/0.0.1 Safari/534.8+ |
||
| 1228 | */ |
||
| 1229 | public static function is_blackberry_tablet() { |
||
| 1245 | |||
| 1246 | /** |
||
| 1247 | * The is_blackbeberry() method can be used to check the User Agent for a blackberry device. |
||
| 1248 | * Note that opera mini on BB matches this rule. |
||
| 1249 | */ |
||
| 1250 | View Code Duplication | public static function is_blackbeberry() { |
|
| 1268 | |||
| 1269 | /** |
||
| 1270 | * The is_blackberry_10() method can be used to check the User Agent for a BlackBerry 10 device. |
||
| 1271 | */ |
||
| 1272 | public static function is_blackberry_10() { |
||
| 1276 | |||
| 1277 | /** |
||
| 1278 | * Retrieve the blackberry OS version. |
||
| 1279 | * |
||
| 1280 | * Return strings are from the following list: |
||
| 1281 | * - blackberry-10 |
||
| 1282 | * - blackberry-7 |
||
| 1283 | * - blackberry-6 |
||
| 1284 | * - blackberry-torch //only the first edition. The 2nd edition has the OS7 onboard and doesn't need any special rule. |
||
| 1285 | * - blackberry-5 |
||
| 1286 | * - blackberry-4.7 |
||
| 1287 | * - blackberry-4.6 |
||
| 1288 | * - blackberry-4.5 |
||
| 1289 | * |
||
| 1290 | * @return string Version of the BB OS. |
||
| 1291 | * If version is not found, get_blackbeberry_OS_version will return boolean false. |
||
| 1292 | */ |
||
| 1293 | public static function get_blackbeberry_OS_version() { |
||
| 1368 | |||
| 1369 | /** |
||
| 1370 | * Retrieve the blackberry browser version. |
||
| 1371 | * |
||
| 1372 | * Return string are from the following list: |
||
| 1373 | * - blackberry-10 |
||
| 1374 | * - blackberry-webkit |
||
| 1375 | * - blackberry-5 |
||
| 1376 | * - blackberry-4.7 |
||
| 1377 | * - blackberry-4.6 |
||
| 1378 | * |
||
| 1379 | * @return string Type of the BB browser. |
||
| 1380 | * If browser's version is not found, detect_blackbeberry_browser_version will return boolean false. |
||
| 1381 | */ |
||
| 1382 | public static function detect_blackberry_browser_version() { |
||
| 1431 | |||
| 1432 | /** |
||
| 1433 | * Checks if a visitor is coming from one of the WordPress mobile apps. |
||
| 1434 | * |
||
| 1435 | * @return bool |
||
| 1436 | */ |
||
| 1437 | public static function is_mobile_app() { |
||
| 1463 | |||
| 1464 | /** |
||
| 1465 | * Detects if the current browser is Nintendo 3DS handheld. |
||
| 1466 | * |
||
| 1467 | * Example: Mozilla/5.0 (Nintendo 3DS; U; ; en) Version/1.7498.US |
||
| 1468 | * can differ in language, version and region |
||
| 1469 | */ |
||
| 1470 | public static function is_Nintendo_3DS() { |
||
| 1481 | |||
| 1482 | /** |
||
| 1483 | * Was the current request made by a known bot? |
||
| 1484 | * |
||
| 1485 | * @return boolean |
||
| 1486 | */ |
||
| 1487 | public static function is_bot() { |
||
| 1496 | |||
| 1497 | /** |
||
| 1498 | * Is the given user-agent a known bot? |
||
| 1499 | * If you want an is_bot check for the current request's UA, use is_bot() instead of passing a user-agent to this method. |
||
| 1500 | * |
||
| 1501 | * @param string $ua A user-agent string. |
||
| 1502 | * |
||
| 1503 | * @return boolean |
||
| 1504 | */ |
||
| 1505 | public static function is_bot_user_agent( $ua = null ) { |
||
| 1580 | } |
||
| 1581 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..