diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eb1c70..dd7aecf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 6.1.1 (released 2016-12-13) + +- Added Samsung Browser detection + ## 6.1.0 (released 2016-10-28) - Fixed issue with blackberry version detection diff --git a/LICENSE b/LICENSE index fe0e8f4..dfe9a79 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2013-2016 Chris Schuld +Copyright (c) 2013-2017 Chris Schuld Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md index 2b65da1..0bdd3c2 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ The Browser class allows you to detect a user's browser and version. * SeaMonkey * Yandex Browser * Comodo Dragon + * Samsung Browser ### Usage diff --git a/composer.json b/composer.json index d025a9a..07b268f 100644 --- a/composer.json +++ b/composer.json @@ -9,9 +9,7 @@ "email": "me@gabrielbull.com" }, { - "name": "Chris Schuld", - "email": "chris@chrisschuld.com", - "homepage": "http://chrisschuld.com" + "name": "Chris Schuld" } ], "require": { @@ -30,11 +28,6 @@ "Sinergi\\BrowserDetector\\Tests\\": ["tests/BrowserDetector/Tests", "tests/BrowserDetector/Tests/_includes"] } }, - "extra": { - "branch-alias": { - "dev-develop": "6.1-dev" - } - }, "minimum-stability": "dev", "prefer-stable": true } diff --git a/src/Browser.php b/src/Browser.php index c78dfff..e40e837 100644 --- a/src/Browser.php +++ b/src/Browser.php @@ -26,6 +26,7 @@ class Browser const AMAYA = 'Amaya'; const LYNX = 'Lynx'; const SAFARI = 'Safari'; + const SAMSUNG_BROWSER = 'SamsungBrowser'; const CHROME = 'Chrome'; const NAVIGATOR = 'Navigator'; const GOOGLEBOT = 'GoogleBot'; diff --git a/src/BrowserDetector.php b/src/BrowserDetector.php index b2a95ce..df07c15 100644 --- a/src/BrowserDetector.php +++ b/src/BrowserDetector.php @@ -43,6 +43,7 @@ class BrowserDetector implements DetectorInterface 'SeaMonkey', 'Firefox', 'Yandex', + 'Samsung', 'Chrome', 'OmniWeb', // common mobile @@ -373,6 +374,27 @@ public static function checkBrowserOpera() return false; } + /** + * Determine if the browser is Samsung. + * + * @return bool + */ + public static function checkBrowserSamsung() + { + if (stripos(self::$userAgentString, 'SamsungBrowser') !== false) { + $aresult = explode('/', stristr(self::$userAgentString, 'SamsungBrowser')); + if (isset($aresult[1])) { + $aversion = explode(' ', $aresult[1]); + self::$browser->setVersion($aversion[0]); + } + self::$browser->setName(Browser::SAMSUNG_BROWSER); + + return true; + } + + return false; + } + /** * Determine if the browser is Chrome. * diff --git a/src/DeviceDetector.php b/src/DeviceDetector.php index b8ea86b..b905944 100644 --- a/src/DeviceDetector.php +++ b/src/DeviceDetector.php @@ -18,7 +18,8 @@ public static function detect(Device $device, UserAgent $userAgent) return ( self::checkIpad($device, $userAgent) || self::checkIphone($device, $userAgent) || - self::checkWindowsPhone($device, $userAgent) + self::checkWindowsPhone($device, $userAgent) || + self::checkSamsungPhone($device, $userAgent) ); } @@ -76,4 +77,21 @@ private static function checkWindowsPhone(Device $device, UserAgent $userAgent) } return false; } + + /** + * Determine if the device is Windows Phone. + * + * @param Device $device + * @param UserAgent $userAgent + * @return bool + */ + private static function checkSamsungPhone(Device $device, UserAgent $userAgent) + { + if (preg_match('/SAMSUNG SM-([^ ]*)/i', $userAgent->getUserAgentString(), $matches)) { + $device->setName(str_ireplace('SAMSUNG', 'Samsung', $matches[0])); + return true; + } + + return false; + } } diff --git a/tests/BrowserDetector/Tests/_files/UserAgentStrings.xml b/tests/BrowserDetector/Tests/_files/UserAgentStrings.xml index b622e8c..0d91a2f 100644 --- a/tests/BrowserDetector/Tests/_files/UserAgentStrings.xml +++ b/tests/BrowserDetector/Tests/_files/UserAgentStrings.xml @@ -252,5 +252,16 @@ Mozilla/5.0 (BlackBerry; U; BlackBerry 9380; en) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.1.0.523 Mobile Safari/534.11+ + + SamsungBrowser + 3.3 + Android + 5.1.1 + Samsung SM-G360T1 + unknown + + Mozilla/5.0 (Linux; Android 5.1.1; SAMSUNG SM-G360T1 Build/LMY47X) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/3.3 Chrome/38.0.2125.102 Mobile Safari/537.36 + +