UserAgent
in package
implements
Stringable
Abstraction for an HTTP user agent
Tags
Table of Contents
Interfaces
- Stringable
Properties
- $agent : string
- Current user-agent
- $browser : string
- Current user-agent browser
- $config : UserAgents
- Holds the config file contents.
- $isBrowser : bool
- Flag for if the user-agent belongs to a browser
- $isMobile : bool
- Flag for if the user-agent is a mobile browser
- $isRobot : bool
- Flag for if the user-agent is a robot
- $mobile : string
- Current user-agent mobile name
- $platform : string
- Current user-agent platform
- $referrer : bool|string|null
- HTTP Referer
- $robot : string
- Current user-agent robot name
- $version : string
- Current user-agent version
Methods
- __construct() : mixed
- Constructor
- __toString() : string
- Outputs the original Agent String when cast as a string.
- getAgentString() : string
- Agent String
- getBrowser() : string
- Get Browser Name
- getMobile() : string
- Get the Mobile Device
- getPlatform() : string
- Get Platform
- getReferrer() : string
- Get the referrer
- getRobot() : string
- Get The Robot Name
- getVersion() : string
- Get the Browser Version
- isBrowser() : bool
- Is Browser
- isMobile() : bool
- Is Mobile
- isReferral() : bool
- Is this a referral from another site?
- isRobot() : bool
- Is Robot
- parse() : void
- Parse a custom user-agent string
- compileData() : void
- Compile the User Agent Data
- setBrowser() : bool
- Set the Browser
- setMobile() : bool
- Set the Mobile Device
- setPlatform() : bool
- Set the Platform
- setRobot() : bool
- Set the Robot
Properties
$agent
Current user-agent
protected
string
$agent
= ''
$browser
Current user-agent browser
protected
string
$browser
= ''
$config
Holds the config file contents.
protected
UserAgents
$config
$isBrowser
Flag for if the user-agent belongs to a browser
protected
bool
$isBrowser
= false
$isMobile
Flag for if the user-agent is a mobile browser
protected
bool
$isMobile
= false
$isRobot
Flag for if the user-agent is a robot
protected
bool
$isRobot
= false
$mobile
Current user-agent mobile name
protected
string
$mobile
= ''
$platform
Current user-agent platform
protected
string
$platform
= ''
$referrer
HTTP Referer
protected
bool|string|null
$referrer
$robot
Current user-agent robot name
protected
string
$robot
= ''
$version
Current user-agent version
protected
string
$version
= ''
Methods
__construct()
Constructor
public
__construct([UserAgents|null $config = null ]) : mixed
Sets the User Agent and runs the compilation routine
Parameters
- $config : UserAgents|null = null
__toString()
Outputs the original Agent String when cast as a string.
public
__toString() : string
Return values
stringgetAgentString()
Agent String
public
getAgentString() : string
Return values
stringgetBrowser()
Get Browser Name
public
getBrowser() : string
Return values
stringgetMobile()
Get the Mobile Device
public
getMobile() : string
Return values
stringgetPlatform()
Get Platform
public
getPlatform() : string
Return values
stringgetReferrer()
Get the referrer
public
getReferrer() : string
Return values
stringgetRobot()
Get The Robot Name
public
getRobot() : string
Return values
stringgetVersion()
Get the Browser Version
public
getVersion() : string
Return values
stringisBrowser()
Is Browser
public
isBrowser([string|null $key = null ]) : bool
Parameters
- $key : string|null = null
Return values
boolisMobile()
Is Mobile
public
isMobile([string|null $key = null ]) : bool
Parameters
- $key : string|null = null
Return values
boolisReferral()
Is this a referral from another site?
public
isReferral() : bool
Return values
boolisRobot()
Is Robot
public
isRobot([string|null $key = null ]) : bool
Parameters
- $key : string|null = null
Return values
boolparse()
Parse a custom user-agent string
public
parse(string $string) : void
Parameters
- $string : string
compileData()
Compile the User Agent Data
protected
compileData() : void
setBrowser()
Set the Browser
protected
setBrowser() : bool
Return values
boolsetMobile()
Set the Mobile Device
protected
setMobile() : bool
Return values
boolsetPlatform()
Set the Platform
protected
setPlatform() : bool
Return values
boolsetRobot()
Set the Robot
protected
setRobot() : bool