UserAgent
in package
Implementation of parser for user-agents.json file
Table of Contents
Constants
- MAX_AGE_HOURS : mixed = 6
Properties
Methods
- __construct() : mixed
- Load the rules file
- getAgentInfo() : array<string|int, mixed>
- Return info about a given user-agent
- getBodyClasses() : mixed
- getDeviceCategory() : mixed
- getInfo() : mixed
- init() : mixed
- pregInject() : mixed
- Replace values in a way similar to preg_replace
- process() : array<string|int, mixed>
- Internal recursive processing method
Constants
MAX_AGE_HOURS
public
mixed
MAX_AGE_HOURS
= 6
Properties
$info
private
static mixed
$info
= []
$rules
private
mixed
$rules
$ua
private
static mixed
$ua
Methods
__construct()
Load the rules file
public
__construct(string $filename) : mixed
Parameters
- $filename : string
-
Filename of the rules file to load
Tags
getAgentInfo()
Return info about a given user-agent
public
getAgentInfo(mixed $ua) : array<string|int, mixed>
Parameters
- $ua : mixed
Return values
array<string|int, mixed> —Keys will only exist if values determined. Possible keys are: 'os_name', 'os_version', 'os_title', 'browser_name', 'browser_version', 'device_category'
getBodyClasses()
public
static getBodyClasses() : mixed
getDeviceCategory()
public
static getDeviceCategory() : mixed
getInfo()
public
static getInfo() : mixed
init()
public
static init() : mixed
pregInject()
Replace values in a way similar to preg_replace
public
pregInject(mixed $text, mixed $matches) : mixed
Parameters
- $text : mixed
- $matches : mixed
process()
Internal recursive processing method
private
process(string $ua, array<string|int, mixed> $rules) : array<string|int, mixed>
Parameters
- $ua : string
-
User agent
- $rules : array<string|int, mixed>
-
Rules extracted from JSON file
Return values
array<string|int, mixed> —Keys will only exist if values determined. Possible keys are: 'on', 'ov', 'ot', 'bn', 'bv', 'dc'