PHP Class phpUserAgentStringParser, php-user-agent

Datei anzeigen Open project: ornicar/php-user-agent Class Usage Examples

Public Methods

Method Description
addFilter ( string $filter ) Add a filter to be called when parsing a user agent
cleanUserAgentString ( string $userAgentString ) : string Make user agent string lowercase, and replace browser aliases
getFilters ( ) : array Get the list of filters that get called when parsing a user agent
parse ( string $userAgentString = null ) : array Parse a user agent string.

Protected Methods

Method Description
doParse ( string $userAgentString ) : array Detect quickly informations from the user agent string
filterAndroid ( array &$userAgent ) Android has a safari like signature
filterGoogleChrome ( array &$userAgent ) Google chrome has a safari like signature
filterMsie ( array &$userAgent ) MSIE does not always declare its engine
filterOperaVersion ( array &$userAgent ) Opera 10.00 (and higher) version number is located at the end
filterSafariVersion ( array &$userAgent ) Safari version is not encoded "normally"
filterYahoo ( array &$userAgent ) Yahoo bot has a special user agent string
getKnownBrowserAliases ( ) : array Get known browser aliases
getKnownBrowsers ( ) : array Get known browsers
getKnownEngineAliases ( ) : array Get known engines aliases
getKnownEngines ( ) : array Get known engines
getKnownOperatingSystemAliases ( ) : array Get known operating system aliases
getKnownOperatingSystems ( ) : array Get known operating system

Method Details

addFilter() public method

Add a filter to be called when parsing a user agent
public addFilter ( string $filter )
$filter string name of the filter method

cleanUserAgentString() public method

Make user agent string lowercase, and replace browser aliases
public cleanUserAgentString ( string $userAgentString ) : string
$userAgentString string the dirty user agent string
return string the clean user agent string

doParse() protected method

Detect quickly informations from the user agent string
protected doParse ( string $userAgentString ) : array
$userAgentString string user agent string
return array user agent informations array

filterAndroid() protected method

Android has a safari like signature
protected filterAndroid ( array &$userAgent )
$userAgent array

filterGoogleChrome() protected method

Google chrome has a safari like signature
protected filterGoogleChrome ( array &$userAgent )
$userAgent array

filterMsie() protected method

MSIE does not always declare its engine
protected filterMsie ( array &$userAgent )
$userAgent array

filterOperaVersion() protected method

Opera 10.00 (and higher) version number is located at the end
protected filterOperaVersion ( array &$userAgent )
$userAgent array

filterSafariVersion() protected method

Safari version is not encoded "normally"
protected filterSafariVersion ( array &$userAgent )
$userAgent array

filterYahoo() protected method

Yahoo bot has a special user agent string
protected filterYahoo ( array &$userAgent )
$userAgent array

getFilters() public method

Get the list of filters that get called when parsing a user agent
public getFilters ( ) : array
return array list of valid callables

getKnownBrowserAliases() protected method

Get known browser aliases
protected getKnownBrowserAliases ( ) : array
return array the browser aliases

getKnownBrowsers() protected method

Get known browsers
protected getKnownBrowsers ( ) : array
return array the browsers

getKnownEngineAliases() protected method

Get known engines aliases
protected getKnownEngineAliases ( ) : array
return array the engines aliases

getKnownEngines() protected method

Get known engines
protected getKnownEngines ( ) : array
return array the engines

getKnownOperatingSystemAliases() protected method

Get known operating system aliases
protected getKnownOperatingSystemAliases ( ) : array
return array the operating system aliases

getKnownOperatingSystems() protected method

Get known operating system
protected getKnownOperatingSystems ( ) : array
return array the operating systems

parse() public method

Parse a user agent string.
public parse ( string $userAgentString = null ) : array
$userAgentString string defaults to $_SERVER['HTTP_USER_AGENT'] if empty
return array ( the user agent informations 'browser_name' => 'firefox', 'browser_version' => '3.6', 'operating_system' => 'linux' )