PHP Class DeviceDetector\Parser\ParserAbstract

Afficher le fichier Open project: piwik/device-detector Class Usage Examples

Protected Properties

Свойство 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

Méthodes publiques

Méthode 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

Méthodes protégées

Méthode 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 méthode

public __construct ( $ua = '' )

buildByMatch() protected méthode

protected buildByMatch ( string $item, array $matches ) : string
$item string
$matches array
Résultat string type

buildVersion() protected méthode

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
Résultat mixed | string

getCache() public méthode

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

getName() public méthode

Returns the internal name of the parser
public getName ( ) : string
Résultat string

getRegexes() protected méthode

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

getRegexesDirectory() protected méthode

protected getRegexesDirectory ( ) : string
Résultat string

getYamlParser() public méthode

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

matchUserAgent() protected méthode

Matches the useragent against the given regex
protected matchUserAgent ( $regex ) : array | boolean
$regex
Résultat array | boolean

parse() abstract public méthode

abstract public parse ( )

preMatchOverall() protected méthode

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
Résultat boolean

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 user agent to parse
public setUserAgent ( string $ua )
$ua string user agent

setVersionTruncation() public static méthode

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

setYamlParser() public méthode

Sets the Cache class
public setYamlParser ( $yamlParser )

Property Details

$cache protected_oe property

protected Cache,DeviceDetector\Cache|CacheProvider,Doctrine\Common\Cache $cache
Résultat DeviceDetector\Cache\Cache | Doctrine\Common\Cache\CacheProvider

$fixtureFile protected_oe property

Holds the path to the yml file containing regexes
protected string $fixtureFile
Résultat string

$globalMethods protected_oe property

Holds an array with method that should be available global
protected array $globalMethods
Résultat 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
Résultat integer

$parserName protected_oe property

Holds the internal name of the parser Used for caching
protected string $parserName
Résultat string

$regexList protected_oe property

Holds an array with regexes to parse, if already loaded
protected array $regexList
Résultat array

$userAgent protected_oe property

Holds the user agent the should be parsed
protected string $userAgent
Résultat string

$yamlParser protected_oe property

protected Parser,DeviceDetector\Yaml $yamlParser
Résultat DeviceDetector\Yaml\Parser