PHP Класс DeviceDetector\DeviceDetector

Magic Device Type Methods
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$clientTypes array Holds all registered client types

Защищенные свойства (Protected)

Свойство Тип Описание
$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

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
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 ( )

Описание методов

__call() публичный Метод

public __call ( $methodName, $arguments )

__construct() публичный Метод

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

addClientParser() публичный Метод

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

addDeviceParser() публичный Метод

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

discardBotInformation() публичный Метод

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

getBot() публичный Метод

Returns the bot extracted from the parsed UA
public getBot ( ) : array
Результат array

getBrand() публичный Метод

Returns the device brand extracted from the parsed UA
См. также: self::$deviceBrand for available device brands
public getBrand ( ) : string
Результат string

getBrandName() публичный Метод

Returns the full device brand name extracted from the parsed UA
См. также: self::$deviceBrand for available device brands
public getBrandName ( ) : string
Результат string

getCache() публичный Метод

Returns Cache object
public getCache ( ) : CacheProvider
Результат Doctrine\Common\Cache\CacheProvider

getClient() публичный Метод

If $attr is given only that property will be returned
public getClient ( string $attr = '' ) : array | string
$attr string property to return(optional)
Результат array | string

getClientParsers() публичный Метод

public getClientParsers ( )

getDevice() публичный Метод

Returns the device type extracted from the parsed UA
См. также: DeviceParserAbstract::$deviceTypes for available device types
public getDevice ( ) : integer | null
Результат integer | null

getDeviceName() публичный Метод

Returns the device type extracted from the parsed UA
См. также: DeviceParserAbstract::$deviceTypes for available device types
public getDeviceName ( ) : string
Результат string

getDeviceParsers() публичный Метод

public getDeviceParsers ( )

getInfoFromUserAgent() публичный статический Метод

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.
Устаревший:
public static getInfoFromUserAgent ( string $ua ) : array
$ua string UserAgent to parse
Результат array

getModel() публичный Метод

Returns the device model extracted from the parsed UA
public getModel ( ) : string
Результат string

getOs() публичный Метод

If $attr is given only that property will be returned
public getOs ( string $attr = '' ) : array | string
$attr string property to return(optional)
Результат array | string

getUserAgent() публичный Метод

Returns the user agent that is set to be parsed
public getUserAgent ( ) : string
Результат string

getYamlParser() публичный Метод

Returns Yaml Parser object
public getYamlParser ( ) : DeviceDetector\Yaml\Parser
Результат DeviceDetector\Yaml\Parser

hasAndroidMobileFragment() защищенный Метод

Returns if the parsed UA contains the 'Android; Mobile;' fragment
protected hasAndroidMobileFragment ( ) : boolean
Результат boolean

hasAndroidTableFragment() защищенный Метод

Returns if the parsed UA contains the 'Android; Tablet;' fragment
protected hasAndroidTableFragment ( ) : boolean
Результат boolean

isBot() публичный Метод

Returns if the parsed UA was identified as a Bot
public isBot ( ) : boolean
Результат boolean

isDesktop() публичный Метод

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
См. также: self::$desktopOsArray
public isDesktop ( ) : boolean
Результат boolean

isMobile() публичный Метод

public isMobile ( )

isParsed() публичный Метод

Returns true, if userAgent was already parsed with parse()
public isParsed ( ) : boolean
Результат boolean

isTouchEnabled() публичный Метод

Note: That only applies to windows 8 tablets
public isTouchEnabled ( ) : boolean
Результат boolean

matchUserAgent() защищенный Метод

protected matchUserAgent ( $regex )

parse() публичный Метод

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

parseBot() защищенный Метод

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

parseClient() защищенный Метод

protected parseClient ( )

parseDevice() защищенный Метод

protected parseDevice ( )

parseOs() защищенный Метод

protected parseOs ( )

reset() защищенный Метод

protected reset ( )

setCache() публичный Метод

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

setUserAgent() публичный Метод

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

setYamlParser() публичный Метод

Sets the Yaml Parser class
public setYamlParser ( $yamlParser )

skipBotDetection() публичный Метод

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 usesMobileBrowser ( )

Описание свойств

$bot защищенное свойство

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
Результат array | boolean

$brand защищенное свойство

Holds the device brand data after parsing the UA
protected string $brand
Результат string

$cache защищенное свойство

Holds the cache class used for caching the parsed yml-Files
protected Cache,DeviceDetector\Cache|CacheProvider,Doctrine\Common\Cache $cache
Результат DeviceDetector\Cache\Cache | Doctrine\Common\Cache\CacheProvider

$client защищенное свойство

Holds the client data after parsing the UA
protected array $client
Результат array

$clientParsers защищенное свойство

protected ClientParserAbstract[],DeviceDetector\Parser\Client $clientParsers
Результат DeviceDetector\Parser\Client\ClientParserAbstract[]

$clientTypes публичное статическое свойство

Holds all registered client types
public static array $clientTypes
Результат array

$desktopOsArray защищенное статическое свойство

Operating system families that are known as desktop only
protected static array $desktopOsArray
Результат array

$device защищенное свойство

Holds the device type after parsing the UA
protected string $device
Результат string

$deviceParsers защищенное свойство

protected DeviceParserAbstract[],DeviceDetector\Parser\Device $deviceParsers
Результат DeviceDetector\Parser\Device\DeviceParserAbstract[]

$discardBotInformation защищенное свойство

protected bool $discardBotInformation
Результат boolean

$model защищенное свойство

Holds the device model data after parsing the UA
protected string $model
Результат string

$os защищенное свойство

Holds the operating system data after parsing the UA
protected array $os
Результат array

$skipBotDetection защищенное свойство

protected bool $skipBotDetection
Результат boolean

$userAgent защищенное свойство

Holds the useragent that should be parsed
protected string $userAgent
Результат string

$yamlParser защищенное свойство

Holds the parser class used for parsing yml-Files
protected Parser,DeviceDetector\Yaml $yamlParser
Результат DeviceDetector\Yaml\Parser