PHP Class DeviceDetector\Parser\ParserAbstract

Datei anzeigen Open project: piwik/device-detector Class Usage Examples

Protected Properties

Property Type Description
$cache DeviceDetector\Cache\Cache | Doctrine\Common\Cache\CacheProvider
$fixtureFile string Holds the path to the yml file containing regexes
$globalMethods array Holds an array with method that should be available global
$maxMinorParts integer Indicates how deep versioning will be detected if $maxMinorParts is 0 only the major version will be returned
$parserName string Holds the internal name of the parser Used for caching
$regexList array Holds an array with regexes to parse, if already loaded
$userAgent string Holds the user agent the should be parsed
$yamlParser DeviceDetector\Yaml\Parser

Public Methods

Method Description
__construct ( $ua = '' )
getCache ( ) : DeviceDetector\Cache\Cache | CacheProvider Returns Cache object
getName ( ) : string Returns the internal name of the parser
getYamlParser ( ) : DeviceDetector\Yaml\Parser Returns Cache object
parse ( )
setCache ( DeviceDetector\Cache\Cache | CacheProvider $cache ) Sets the Cache class
setUserAgent ( string $ua ) Sets the user agent to parse
setVersionTruncation ( integer | null $type ) Set how DeviceDetector should return versions
setYamlParser ( $yamlParser ) Sets the Cache class

Protected Methods

Method Description
buildByMatch ( string $item, array $matches ) : string
buildVersion ( $versionString, $matches ) : mixed | string Builds the version with the given $versionString and $matches
getRegexes ( ) : array Returns the result of the parsed yml file defined in $fixtureFile
getRegexesDirectory ( ) : string
matchUserAgent ( $regex ) : array | boolean Matches the useragent against the given regex
preMatchOverall ( ) : boolean Tests the useragent against a combination of all regexes

Method Details

__construct() public method

public __construct ( $ua = '' )

buildByMatch() protected method

protected buildByMatch ( string $item, array $matches ) : string
$item string
$matches array
return string type

buildVersion() protected method

Example: $versionString = 'v$2' $matches = array('version_1_0_1', '1_0_1') return value would be v1.0.1
protected buildVersion ( $versionString, $matches ) : mixed | string
$versionString
$matches
return mixed | string

getCache() public method

Returns Cache object
public getCache ( ) : DeviceDetector\Cache\Cache | CacheProvider
return DeviceDetector\Cache\Cache | Doctrine\Common\Cache\CacheProvider

getName() public method

Returns the internal name of the parser
public getName ( ) : string
return string

getRegexes() protected method

Returns the result of the parsed yml file defined in $fixtureFile
protected getRegexes ( ) : array
return array

getRegexesDirectory() protected method

protected getRegexesDirectory ( ) : string
return string

getYamlParser() public method

Returns Cache object
public getYamlParser ( ) : DeviceDetector\Yaml\Parser
return DeviceDetector\Yaml\Parser

matchUserAgent() protected method

Matches the useragent against the given regex
protected matchUserAgent ( $regex ) : array | boolean
$regex
return array | boolean

parse() abstract public method

abstract public parse ( )

preMatchOverall() protected method

All regexes returned by getRegexes() will be reversed and concated with '|' Afterwards the big regex will be tested against the user agent Method can be used to speed up detections by making a big check before doing checks for every single regex
protected preMatchOverall ( ) : boolean
return boolean

setCache() public method

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

setUserAgent() public method

Sets the user agent to parse
public setUserAgent ( string $ua )
$ua string user agent

setVersionTruncation() public static method

Set how DeviceDetector should return versions
public static setVersionTruncation ( integer | null $type )
$type integer | null Any of the VERSION_TRUNCATION_* constants

setYamlParser() public method

Sets the Cache class
public setYamlParser ( $yamlParser )

Property Details

$cache protected_oe property

protected Cache,DeviceDetector\Cache|CacheProvider,Doctrine\Common\Cache $cache
return DeviceDetector\Cache\Cache | Doctrine\Common\Cache\CacheProvider

$fixtureFile protected_oe property

Holds the path to the yml file containing regexes
protected string $fixtureFile
return string

$globalMethods protected_oe property

Holds an array with method that should be available global
protected array $globalMethods
return array

$maxMinorParts protected_oe static_oe property

Indicates how deep versioning will be detected if $maxMinorParts is 0 only the major version will be returned
protected static int $maxMinorParts
return integer

$parserName protected_oe property

Holds the internal name of the parser Used for caching
protected string $parserName
return string

$regexList protected_oe property

Holds an array with regexes to parse, if already loaded
protected array $regexList
return array

$userAgent protected_oe property

Holds the user agent the should be parsed
protected string $userAgent
return string

$yamlParser protected_oe property

protected Parser,DeviceDetector\Yaml $yamlParser
return DeviceDetector\Yaml\Parser