Skip to content
This repository was archived by the owner on Jan 25, 2023. It is now read-only.

Commit bf61277

Browse files
committed
Added sumsung browser detection
1 parent 8f2f132 commit bf61277

File tree

8 files changed

+60
-10
lines changed

8 files changed

+60
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 6.1.1 (released 2016-12-13)
4+
5+
- Added Samsung Browser detection
6+
37
## 6.1.0 (released 2016-10-28)
48

59
- Fixed issue with blackberry version detection

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2013-2016 Chris Schuld <[email protected]>
3+
Copyright (c) 2013-2017 Chris Schuld <[email protected]>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ The Browser class allows you to detect a user's browser and version.
6868
* SeaMonkey
6969
* Yandex Browser
7070
* Comodo Dragon
71+
* Samsung Browser
7172

7273
### Usage
7374

composer.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
"email": "[email protected]"
1010
},
1111
{
12-
"name": "Chris Schuld",
13-
"email": "[email protected]",
14-
"homepage": "http://chrisschuld.com"
12+
"name": "Chris Schuld"
1513
}
1614
],
1715
"require": {
@@ -30,11 +28,6 @@
3028
"Sinergi\\BrowserDetector\\Tests\\": ["tests/BrowserDetector/Tests", "tests/BrowserDetector/Tests/_includes"]
3129
}
3230
},
33-
"extra": {
34-
"branch-alias": {
35-
"dev-develop": "6.1-dev"
36-
}
37-
},
3831
"minimum-stability": "dev",
3932
"prefer-stable": true
4033
}

src/Browser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class Browser
2626
const AMAYA = 'Amaya';
2727
const LYNX = 'Lynx';
2828
const SAFARI = 'Safari';
29+
const SAMSUNG_BROWSER = 'SamsungBrowser';
2930
const CHROME = 'Chrome';
3031
const NAVIGATOR = 'Navigator';
3132
const GOOGLEBOT = 'GoogleBot';

src/BrowserDetector.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class BrowserDetector implements DetectorInterface
4343
'SeaMonkey',
4444
'Firefox',
4545
'Yandex',
46+
'Samsung',
4647
'Chrome',
4748
'OmniWeb',
4849
// common mobile
@@ -373,6 +374,27 @@ public static function checkBrowserOpera()
373374
return false;
374375
}
375376

377+
/**
378+
* Determine if the browser is Samsung.
379+
*
380+
* @return bool
381+
*/
382+
public static function checkBrowserSamsung()
383+
{
384+
if (stripos(self::$userAgentString, 'SamsungBrowser') !== false) {
385+
$aresult = explode('/', stristr(self::$userAgentString, 'SamsungBrowser'));
386+
if (isset($aresult[1])) {
387+
$aversion = explode(' ', $aresult[1]);
388+
self::$browser->setVersion($aversion[0]);
389+
}
390+
self::$browser->setName(Browser::SAMSUNG_BROWSER);
391+
392+
return true;
393+
}
394+
395+
return false;
396+
}
397+
376398
/**
377399
* Determine if the browser is Chrome.
378400
*

src/DeviceDetector.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public static function detect(Device $device, UserAgent $userAgent)
1818
return (
1919
self::checkIpad($device, $userAgent) ||
2020
self::checkIphone($device, $userAgent) ||
21-
self::checkWindowsPhone($device, $userAgent)
21+
self::checkWindowsPhone($device, $userAgent) ||
22+
self::checkSamsungPhone($device, $userAgent)
2223
);
2324
}
2425

@@ -76,4 +77,21 @@ private static function checkWindowsPhone(Device $device, UserAgent $userAgent)
7677
}
7778
return false;
7879
}
80+
81+
/**
82+
* Determine if the device is Windows Phone.
83+
*
84+
* @param Device $device
85+
* @param UserAgent $userAgent
86+
* @return bool
87+
*/
88+
private static function checkSamsungPhone(Device $device, UserAgent $userAgent)
89+
{
90+
if (preg_match('/SAMSUNG SM-([^ ]*)/i', $userAgent->getUserAgentString(), $matches)) {
91+
$device->setName(str_ireplace('SAMSUNG', 'Samsung', $matches[0]));
92+
return true;
93+
}
94+
95+
return false;
96+
}
7997
}

tests/BrowserDetector/Tests/_files/UserAgentStrings.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,5 +252,16 @@
252252
Mozilla/5.0 (BlackBerry; U; BlackBerry 9380; en) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.1.0.523 Mobile Safari/534.11+
253253
</field>
254254
</string>
255+
<string>
256+
<field name="browser">SamsungBrowser</field>
257+
<field name="version">3.3</field>
258+
<field name="os">Android</field>
259+
<field name="os_version">5.1.1</field>
260+
<field name="device">Samsung SM-G360T1</field>
261+
<field name="device_version">unknown</field>
262+
<field name="string">
263+
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
264+
</field>
265+
</string>
255266
</strings>
256267
</document>

0 commit comments

Comments
 (0)