PHP Class BrowscapPHP\Parser\Helper\Pattern

Author: Christoph Ziegenberg ([email protected])
Author: Thomas Müller ([email protected])
Afficher le fichier Open project: browscap/browscap-php Class Usage Examples

Méthodes publiques

Méthode Description
getHashForParts ( $pattern ) : string returns a hash for one pattern
getHashForPattern ( string $pattern, boolean $variants = false ) : string | array Gets a hash or an array of hashes from the first characters of a pattern/user agent, that can be used for a fast comparison, by comparing only the hashes, without having to match the complete pattern against the user agent.
getPatternLength ( string $pattern ) : integer Gets the minimum length of the patern (used in the getPatterns() method to check against the user agent length)

Method Details

getHashForParts() public static méthode

returns a hash for one pattern
public static getHashForParts ( $pattern ) : string
$pattern
Résultat string

getHashForPattern() public static méthode

With the variants options, all variants from the maximum number of pattern characters to one character will be returned. This is required in some cases, the a placeholder is used very early in the pattern. Example: Pattern: "Mozilla/* (Nintendo 3DS; *) Version/*" User agent: "Mozilla/5.0 (Nintendo 3DS; U; ; en) Version/1.7567.US" In this case the has for the pattern is created for "Mozilla/" while the pattern for the hash for user agent is created for "Mozilla/5.0". The variants option results in an array with hashes for "Mozilla/5.0", "Mozilla/5.", "Mozilla/5", "Mozilla/" ... "M", so that the pattern hash is included.
public static getHashForPattern ( string $pattern, boolean $variants = false ) : string | array
$pattern string
$variants boolean
Résultat string | array

getPatternLength() public static méthode

Gets the minimum length of the patern (used in the getPatterns() method to check against the user agent length)
public static getPatternLength ( string $pattern ) : integer
$pattern string
Résultat integer