PHP Class DeviceDetector\DeviceDetector

Magic Device Type Methods
Afficher le fichier Open project: piwik/device-detector Class Usage Examples

Méthodes publiques

Свойство Type Description
$clientTypes array Holds all registered client types

Protected Properties

Свойство Type Description
$bot array | boolean If $discardBotInformation is set to true, this property will be set to true if parsed UA is identified as bot, additional information will be not available If $skipBotDetection is set to true, bot detection will not be performed and isBot will always be false
$brand string Holds the device brand data after parsing the UA
$cache DeviceDetector\Cache\Cache | Doctrine\Common\Cache\CacheProvider Holds the cache class used for caching the parsed yml-Files
$client array Holds the client data after parsing the UA
$clientParsers DeviceDetector\Parser\Client\ClientParserAbstract[]
$desktopOsArray array Operating system families that are known as desktop only
$device string Holds the device type after parsing the UA
$deviceParsers DeviceDetector\Parser\Device\DeviceParserAbstract[]
$discardBotInformation boolean
$model string Holds the device model data after parsing the UA
$os array Holds the operating system data after parsing the UA
$skipBotDetection boolean
$userAgent string Holds the useragent that should be parsed
$yamlParser DeviceDetector\Yaml\Parser Holds the parser class used for parsing yml-Files

Méthodes publiques

Méthode Description
__call ( $methodName, $arguments )
__construct ( string $userAgent = '' ) Constructor
addClientParser ( DeviceDetector\Parser\Client\ClientParserAbstract | string $parser )
addDeviceParser ( DeviceParserAbstract | string $parser )
discardBotInformation ( boolean $discard = true ) Sets whether to discard additional bot information If information is discarded it's only possible check whether UA was detected as bot or not.
getBot ( ) : array Returns the bot extracted from the parsed UA
getBrand ( ) : string Returns the device brand extracted from the parsed UA
getBrandName ( ) : string Returns the full device brand name extracted from the parsed UA
getCache ( ) : CacheProvider Returns Cache object
getClient ( string $attr = '' ) : array | string Returns the client data extracted from the parsed UA
getClientParsers ( )
getDevice ( ) : integer | null Returns the device type extracted from the parsed UA
getDeviceName ( ) : string Returns the device type extracted from the parsed UA
getDeviceParsers ( )
getInfoFromUserAgent ( string $ua ) : array Parses a useragent and returns the detected data
getModel ( ) : string Returns the device model extracted from the parsed UA
getOs ( string $attr = '' ) : array | string Returns the operating system data extracted from the parsed UA
getUserAgent ( ) : string Returns the user agent that is set to be parsed
getYamlParser ( ) : DeviceDetector\Yaml\Parser Returns Yaml Parser object
isBot ( ) : boolean Returns if the parsed UA was identified as a Bot
isDesktop ( ) : boolean Returns if the parsed UA was identified as desktop device Desktop devices are all devices with an unknown type that are running a desktop os
isMobile ( )
isParsed ( ) : boolean Returns true, if userAgent was already parsed with parse()
isTouchEnabled ( ) : boolean Returns if the parsed UA was identified as a touch enabled device
parse ( ) Triggers the parsing of the current user agent
setCache ( DeviceDetector\Cache\Cache | CacheProvider $cache ) Sets the Cache class
setUserAgent ( string $userAgent ) Sets the useragent to be parsed
setYamlParser ( $yamlParser ) Sets the Yaml Parser class
skipBotDetection ( boolean $skip = true ) Sets whether to skip bot detection.

Méthodes protégées

Méthode Description
hasAndroidMobileFragment ( ) : boolean Returns if the parsed UA contains the 'Android; Mobile;' fragment
hasAndroidTableFragment ( ) : boolean Returns if the parsed UA contains the 'Android; Tablet;' fragment
matchUserAgent ( $regex )
parseBot ( ) Parses the UA for bot information using the Bot parser
parseClient ( )
parseDevice ( )
parseOs ( )
reset ( )
usesMobileBrowser ( )

Method Details

__call() public méthode

public __call ( $methodName, $arguments )

__construct() public méthode

Constructor
public __construct ( string $userAgent = '' )
$userAgent string UA to parse

addClientParser() public méthode

public addClientParser ( DeviceDetector\Parser\Client\ClientParserAbstract | string $parser )
$parser DeviceDetector\Parser\Client\ClientParserAbstract | string

addDeviceParser() public méthode

public addDeviceParser ( DeviceParserAbstract | string $parser )
$parser DeviceDetector\Parser\Device\DeviceParserAbstract | string

discardBotInformation() public méthode

(Discarding information speeds up the detection a bit)
public discardBotInformation ( boolean $discard = true )
$discard boolean

getBot() public méthode

Returns the bot extracted from the parsed UA
public getBot ( ) : array
Résultat array

getBrand() public méthode

Returns the device brand extracted from the parsed UA
See also: self::$deviceBrand for available device brands
public getBrand ( ) : string
Résultat string

getBrandName() public méthode

Returns the full device brand name extracted from the parsed UA
See also: self::$deviceBrand for available device brands
public getBrandName ( ) : string
Résultat string

getCache() public méthode

Returns Cache object
public getCache ( ) : CacheProvider
Résultat Doctrine\Common\Cache\CacheProvider

getClient() public méthode

If $attr is given only that property will be returned
public getClient ( string $attr = '' ) : array | string
$attr string property to return(optional)
Résultat array | string

getClientParsers() public méthode

public getClientParsers ( )

getDevice() public méthode

Returns the device type extracted from the parsed UA
See also: DeviceParserAbstract::$deviceTypes for available device types
public getDevice ( ) : integer | null
Résultat integer | null

getDeviceName() public méthode

Returns the device type extracted from the parsed UA
See also: DeviceParserAbstract::$deviceTypes for available device types
public getDeviceName ( ) : string
Résultat string

getDeviceParsers() public méthode

public getDeviceParsers ( )

getInfoFromUserAgent() public static méthode

ATTENTION: Use that method only for testing or very small applications To get fast results from DeviceDetector you need to make your own implementation, that should use one of the caching mechanisms. See README.md for more information.
Deprecation:
public static getInfoFromUserAgent ( string $ua ) : array
$ua string UserAgent to parse
Résultat array

getModel() public méthode

Returns the device model extracted from the parsed UA
public getModel ( ) : string
Résultat string

getOs() public méthode

If $attr is given only that property will be returned
public getOs ( string $attr = '' ) : array | string
$attr string property to return(optional)
Résultat array | string

getUserAgent() public méthode

Returns the user agent that is set to be parsed
public getUserAgent ( ) : string
Résultat string

getYamlParser() public méthode

Returns Yaml Parser object
public getYamlParser ( ) : DeviceDetector\Yaml\Parser
Résultat DeviceDetector\Yaml\Parser

hasAndroidMobileFragment() protected méthode

Returns if the parsed UA contains the 'Android; Mobile;' fragment
protected hasAndroidMobileFragment ( ) : boolean
Résultat boolean

hasAndroidTableFragment() protected méthode

Returns if the parsed UA contains the 'Android; Tablet;' fragment
protected hasAndroidTableFragment ( ) : boolean
Résultat boolean

isBot() public méthode

Returns if the parsed UA was identified as a Bot
public isBot ( ) : boolean
Résultat boolean

isDesktop() public méthode

Returns if the parsed UA was identified as desktop device Desktop devices are all devices with an unknown type that are running a desktop os
See also: self::$desktopOsArray
public isDesktop ( ) : boolean
Résultat boolean

isMobile() public méthode

public isMobile ( )

isParsed() public méthode

Returns true, if userAgent was already parsed with parse()
public isParsed ( ) : boolean
Résultat boolean

isTouchEnabled() public méthode

Note: That only applies to windows 8 tablets
public isTouchEnabled ( ) : boolean
Résultat boolean

matchUserAgent() protected méthode

protected matchUserAgent ( $regex )

parse() public méthode

Triggers the parsing of the current user agent
public parse ( )

parseBot() protected méthode

Parses the UA for bot information using the Bot parser
protected parseBot ( )

parseClient() protected méthode

protected parseClient ( )

parseDevice() protected méthode

protected parseDevice ( )

parseOs() protected méthode

protected parseOs ( )

reset() protected méthode

protected reset ( )

setCache() public méthode

Sets the Cache class
public setCache ( DeviceDetector\Cache\Cache | CacheProvider $cache )
$cache DeviceDetector\Cache\Cache | Doctrine\Common\Cache\CacheProvider

setUserAgent() public méthode

Sets the useragent to be parsed
public setUserAgent ( string $userAgent )
$userAgent string

setYamlParser() public méthode

Sets the Yaml Parser class
public setYamlParser ( $yamlParser )

skipBotDetection() public méthode

It is needed if we want bots to be processed as a simple clients. So we can detect if it is mobile client, or desktop, or enything else. By default all this information is not retrieved for the bots.
public skipBotDetection ( boolean $skip = true )
$skip boolean

usesMobileBrowser() protected méthode

protected usesMobileBrowser ( )

Property Details

$bot protected_oe property

If $discardBotInformation is set to true, this property will be set to true if parsed UA is identified as bot, additional information will be not available If $skipBotDetection is set to true, bot detection will not be performed and isBot will always be false
protected array|bool $bot
Résultat array | boolean

$brand protected_oe property

Holds the device brand data after parsing the UA
protected string $brand
Résultat string

$cache protected_oe property

Holds the cache class used for caching the parsed yml-Files
protected Cache,DeviceDetector\Cache|CacheProvider,Doctrine\Common\Cache $cache
Résultat DeviceDetector\Cache\Cache | Doctrine\Common\Cache\CacheProvider

$client protected_oe property

Holds the client data after parsing the UA
protected array $client
Résultat array

$clientParsers protected_oe property

protected ClientParserAbstract[],DeviceDetector\Parser\Client $clientParsers
Résultat DeviceDetector\Parser\Client\ClientParserAbstract[]

$clientTypes public_oe static_oe property

Holds all registered client types
public static array $clientTypes
Résultat array

$desktopOsArray protected_oe static_oe property

Operating system families that are known as desktop only
protected static array $desktopOsArray
Résultat array

$device protected_oe property

Holds the device type after parsing the UA
protected string $device
Résultat string

$deviceParsers protected_oe property

protected DeviceParserAbstract[],DeviceDetector\Parser\Device $deviceParsers
Résultat DeviceDetector\Parser\Device\DeviceParserAbstract[]

$discardBotInformation protected_oe property

protected bool $discardBotInformation
Résultat boolean

$model protected_oe property

Holds the device model data after parsing the UA
protected string $model
Résultat string

$os protected_oe property

Holds the operating system data after parsing the UA
protected array $os
Résultat array

$skipBotDetection protected_oe property

protected bool $skipBotDetection
Résultat boolean

$userAgent protected_oe property

Holds the useragent that should be parsed
protected string $userAgent
Résultat string

$yamlParser protected_oe property

Holds the parser class used for parsing yml-Files
protected Parser,DeviceDetector\Yaml $yamlParser
Résultat DeviceDetector\Yaml\Parser