Aplus Framework Docs

UserAgent
in package
implements JsonSerializable, Stringable

Class UserAgent.

Interfaces, Classes, Traits and Enums

JsonSerializable
Stringable

Table of Contents

$agent  : string|null
$browser  : string|null
$browserVersion  : string|null
$config  : array<string|int, mixed>
$isBrowser  : bool
$isMobile  : bool
$isRobot  : bool
$mobile  : string|null
$platform  : string|null
$robot  : string|null
__construct()  : mixed
UserAgent constructor.
__toString()  : string
getAsString()  : string
getBrowser()  : string|null
Gets the Browser name.
getBrowserVersion()  : string|null
Gets the Browser Version.
getMobile()  : string|null
Gets the Mobile device.
getName()  : string
getPlatform()  : string|null
Gets the OS Platform.
getRobot()  : string|null
Gets the Robot name.
getType()  : string
isBrowser()  : bool
Is Browser.
isMobile()  : bool
Is Mobile.
isRobot()  : bool
Is Robot.
jsonSerialize()  : string
toString()  : string
Get the User-Agent as string.
compileData()  : void
parse()  : static
setBrowser()  : bool
setMobile()  : bool
setPlatform()  : bool
setRobot()  : bool

Properties

$browser

protected string|null $browser = null

$browserVersion

protected string|null $browserVersion = null

$config

protected static array<string|int, mixed> $config = [ 'platforms' => ['windows nt 10.0' => 'Windows 10', 'windows nt 6.3' => 'Windows 8.1', 'windows nt 6.2' => 'Windows 8', 'windows nt 6.1' => 'Windows 7', 'windows nt 6.0' => 'Windows Vista', 'windows nt 5.2' => 'Windows 2003', 'windows nt 5.1' => 'Windows XP', 'windows nt 5.0' => 'Windows 2000', 'windows nt 4.0' => 'Windows NT 4.0', 'winnt4.0' => 'Windows NT 4.0', 'winnt 4.0' => 'Windows NT', 'winnt' => 'Windows NT', 'windows 98' => 'Windows 98', 'win98' => 'Windows 98', 'windows 95' => 'Windows 95', 'win95' => 'Windows 95', 'windows phone' => 'Windows Phone', 'windows' => 'Unknown Windows OS', 'android' => 'Android', 'blackberry' => 'BlackBerry', 'iphone' => 'iOS', 'ipad' => 'iOS', 'ipod' => 'iOS', 'os x' => 'Mac OS X', 'ppc mac' => 'Power PC Mac', 'freebsd' => 'FreeBSD', 'ppc' => 'Macintosh', 'ubuntu' => 'Ubuntu', 'debian' => 'Debian', 'fedora' => 'Fedora', 'linux' => 'Linux', 'sunos' => 'Sun Solaris', 'beos' => 'BeOS', 'apachebench' => 'ApacheBench', 'aix' => 'AIX', 'irix' => 'Irix', 'osf' => 'DEC OSF', 'hp-ux' => 'HP-UX', 'netbsd' => 'NetBSD', 'bsdi' => 'BSDi', 'openbsd' => 'OpenBSD', 'gnu' => 'GNU/Linux', 'unix' => 'Unknown Unix OS', 'symbian' => 'Symbian OS'], // The order of this array should NOT be changed. Many browsers return // multiple browser types so we want to identify the sub-type first. 'browsers' => [ 'curl' => 'Curl', 'PostmanRuntime' => 'Postman', 'OPR' => 'Opera', 'Flock' => 'Flock', 'Edge' => 'Spartan', 'Edg' => 'Edge', 'EdgA' => 'Edge', 'Chrome' => 'Chrome', // Opera 10+ always reports Opera/9.80 and appends // Version/<real version> to the user agent string 'Opera.*?Version' => 'Opera', 'Opera' => 'Opera', 'MSIE' => 'Internet Explorer', 'Internet Explorer' => 'Internet Explorer', 'Trident.* rv' => 'Internet Explorer', 'Shiira' => 'Shiira', 'Firefox' => 'Firefox', 'Chimera' => 'Chimera', 'Phoenix' => 'Phoenix', 'Firebird' => 'Firebird', 'Camino' => 'Camino', 'Netscape' => 'Netscape', 'OmniWeb' => 'OmniWeb', 'Safari' => 'Safari', 'Mozilla' => 'Mozilla', 'Konqueror' => 'Konqueror', 'icab' => 'iCab', 'Lynx' => 'Lynx', 'Links' => 'Links', 'hotjava' => 'HotJava', 'amaya' => 'Amaya', 'IBrowse' => 'IBrowse', 'Maxthon' => 'Maxthon', 'Ubuntu' => 'Ubuntu Web Browser', 'Vivaldi' => 'Vivaldi', ], 'mobiles' => [ 'mobileexplorer' => 'Mobile Explorer', 'palmsource' => 'Palm', 'palmscape' => 'Palmscape', // Phones and Manufacturers 'motorola' => 'Motorola', 'nokia' => 'Nokia', 'palm' => 'Palm', 'iphone' => 'Apple iPhone', 'ipad' => 'iPad', 'ipod' => 'Apple iPod Touch', 'sony' => 'Sony Ericsson', 'ericsson' => 'Sony Ericsson', 'blackberry' => 'BlackBerry', 'cocoon' => 'O2 Cocoon', 'blazer' => 'Treo', 'lg' => 'LG', 'amoi' => 'Amoi', 'xda' => 'XDA', 'mda' => 'MDA', 'vario' => 'Vario', 'htc' => 'HTC', 'samsung' => 'Samsung', 'sharp' => 'Sharp', 'sie-' => 'Siemens', 'alcatel' => 'Alcatel', 'benq' => 'BenQ', 'ipaq' => 'HP iPaq', 'mot-' => 'Motorola', 'playstation portable' => 'PlayStation Portable', 'playstation 3' => 'PlayStation 3', 'playstation vita' => 'PlayStation Vita', 'hiptop' => 'Danger Hiptop', 'nec-' => 'NEC', 'panasonic' => 'Panasonic', 'philips' => 'Philips', 'sagem' => 'Sagem', 'sanyo' => 'Sanyo', 'spv' => 'SPV', 'zte' => 'ZTE', 'sendo' => 'Sendo', 'nintendo dsi' => 'Nintendo DSi', 'nintendo ds' => 'Nintendo DS', 'nintendo 3ds' => 'Nintendo 3DS', 'wii' => 'Nintendo Wii', 'open web' => 'Open Web', 'openweb' => 'OpenWeb', // Operating Systems 'android' => 'Android', 'symbian' => 'Symbian', 'SymbianOS' => 'SymbianOS', 'elaine' => 'Palm', 'series60' => 'Symbian S60', 'windows ce' => 'Windows CE', // Browsers 'obigo' => 'Obigo', 'netfront' => 'Netfront Browser', 'openwave' => 'Openwave Browser', 'mobilexplorer' => 'Mobile Explorer', 'operamini' => 'Opera Mini', 'opera mini' => 'Opera Mini', 'opera mobi' => 'Opera Mobile', 'fennec' => 'Firefox Mobile', // Other 'digital paths' => 'Digital Paths', 'avantgo' => 'AvantGo', 'xiino' => 'Xiino', 'novarra' => 'Novarra Transcoder', 'vodafone' => 'Vodafone', 'docomo' => 'NTT DoCoMo', 'o2' => 'O2', // Fallback 'mobile' => 'Generic Mobile', 'wireless' => 'Generic Mobile', 'j2me' => 'Generic Mobile', 'midp' => 'Generic Mobile', 'cldc' => 'Generic Mobile', 'up.link' => 'Generic Mobile', 'up.browser' => 'Generic Mobile', 'smartphone' => 'Generic Mobile', 'cellphone' => 'Generic Mobile', ], 'robots' => ['googlebot' => 'Googlebot', 'msnbot' => 'MSNBot', 'baiduspider' => 'Baiduspider', 'bingbot' => 'Bing', 'slurp' => 'Inktomi Slurp', 'yahoo' => 'Yahoo', 'ask jeeves' => 'Ask Jeeves', 'fastcrawler' => 'FastCrawler', 'infoseek' => 'InfoSeek Robot 1.0', 'lycos' => 'Lycos', 'yandex' => 'YandexBot', 'mediapartners-google' => 'MediaPartners Google', 'CRAZYWEBCRAWLER' => 'Crazy Webcrawler', 'adsbot-google' => 'AdsBot Google', 'feedfetcher-google' => 'Feedfetcher Google', 'curious george' => 'Curious George', 'ia_archiver' => 'Alexa Crawler', 'MJ12bot' => 'Majestic-12', 'Uptimebot' => 'Uptimebot'], ]

$isBrowser

protected bool $isBrowser = false

$mobile

protected string|null $mobile = null

$platform

protected string|null $platform = null

Methods

__construct()

UserAgent constructor.

public __construct(string $userAgent) : mixed
Parameters
$userAgent : string

User-Agent string

Return values
mixed

__toString()

public __toString() : string
Return values
string

getBrowser()

Gets the Browser name.

public getBrowser() : string|null
Return values
string|null

getBrowserVersion()

Gets the Browser Version.

public getBrowserVersion() : string|null
Return values
string|null

getMobile()

Gets the Mobile device.

public getMobile() : string|null
Return values
string|null

getName()

public getName() : string
Return values
string

getPlatform()

Gets the OS Platform.

public getPlatform() : string|null
Return values
string|null

getRobot()

Gets the Robot name.

public getRobot() : string|null
Return values
string|null

getType()

public getType() : string
Return values
string

isBrowser()

Is Browser.

public isBrowser([string|null $key = null ]) : bool
Parameters
$key : string|null = null
Return values
bool

isMobile()

Is Mobile.

public isMobile([string|null $key = null ]) : bool
Parameters
$key : string|null = null
Return values
bool

isRobot()

Is Robot.

public isRobot([string|null $key = null ]) : bool
Parameters
$key : string|null = null
Return values
bool

jsonSerialize()

public jsonSerialize() : string
Return values
string

toString()

Get the User-Agent as string.

public toString() : string
Tags
since
5.3
Return values
string

compileData()

protected compileData() : void
Return values
void

parse()

protected parse(string $string) : static
Parameters
$string : string
Return values
static

setBrowser()

protected setBrowser() : bool
Return values
bool

setMobile()

protected setMobile() : bool
Return values
bool

setPlatform()

protected setPlatform() : bool
Return values
bool

setRobot()

protected setRobot() : bool
Return values
bool

Search results