Skip to content

Commit d739edd

Browse files
committed
wip
1 parent ea2cd73 commit d739edd

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/Utills/Detector.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class Detector
66
{
77
/**
8-
* Get browser list names.
8+
* An array of browser names.
99
*
1010
* @var array
1111
*/
@@ -57,6 +57,18 @@ public function getBrowser(): string
5757
*/
5858
public function getDevice(): string
5959
{
60-
return php_uname('s');
60+
if (PHP_SAPI === 'cli') {
61+
return 'CLI';
62+
}
63+
64+
$userAgent = $_SERVER['HTTP_USER_AGENT'];
65+
66+
foreach ($this->deviceName as $pattern => $name) {
67+
if (preg_match($pattern, $userAgent)) {
68+
return $name;
69+
}
70+
}
71+
72+
return 'Unknown Device Name';
6173
}
6274
}

0 commit comments

Comments
 (0)