Constants

UA_RULES

UA_RULES = 'uar'

Properties

$treeProvider

$treeProvider : 

Type

$branch

$branch : 

Type

$propMatcherIdsInUse

$propMatcherIdsInUse : 

Type

$rulePropIdsInUse

$rulePropIdsInUse : 

Type

$regexes

$regexes : 

Type

Methods

__construct()

__construct(  $tree) 

Parameters

$tree
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

propIsOutput()

propIsOutput(integer  $propertyId) : TRUE

Check if the property is used in the rules and so can be found from them.

This is used in Api.getProperty() to avoid calling the methods in the class if the property that is being looked for cannot be found here.

Parameters

integer $propertyId

The ID of the property that is sought

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

TRUE —

if the propertyId is used, FALSE otherwise

getRequiredProperties()

getRequiredProperties() : \The

Get a list of all the required properties that are needed for this class to properly run its rules.

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

\The —

list of required properties.

putProperties()

putProperties(string  $userAgent, array  $props2Vals, array  $sought) 

Merge the tree walk properties with the User-Agent string properties using the User-Agent rules

Parameters

string $userAgent

The User-Agent to find properties for

array $props2Vals

The results of the tree walk, map of property id to value id

array $sought

A set of properties to return values for

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

_initGetMatcherPropertyIds()

_initGetMatcherPropertyIds(array  $group) 

Find all the properties that are used for matching. This is needed in case the Api.getProperty() function is called as we need these properties for the User-Agent extraction rules to work correctly.

Parameters

array $group

The rule group that can contain a property matcher

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

_initRuleSets()

_initRuleSets(array  $group) : array

Prepare the rule set by extracting it from the current group and counting the items in the group. This is done to avoid counting the items on every request.

Parameters

array $group

The current parent group.

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

array —

A list of all rule sets

_init()

_init() 

Initiliase some data structures to avoid doing it during requests

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

_initGetRulePropertyIds()

_initGetRulePropertyIds(array  $sets) 

Find all the properties that are used in the final rules. This is needed to optimise the Api.getProperty() function.

Parameters

array $sets

The rule set from the main rule group

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

_skipUaRules()

_skipUaRules(  $props2Vals) : TRUE

Check list of items that skip rules - these are typically non-mobile boolean properties such as isBrowser, isBot, isCrawler etc

Parameters

$props2Vals
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

TRUE —

if the UA rules are to be skipped, FALSE if they are to be run

_getUaPropertyRules()

_getUaPropertyRules(string  $userAgent, array  $props2Vals) : \An

Try and find a set of property extraction rules to run on the User-Agent. This is done in two ways.

The first way uses properties found from the tree walk to identify the User-Agent type. If there are still multiple UA types then refining regexes can be run.

If the above approach fails to find a match then fall back to the second way which uses a more brute regex search approach.

Once the UA type is known the correct set of property extraction rules can be returned.

Parameters

string $userAgent

The User-Agent to find properties for

array $props2Vals

The results of the tree walk, map of property id to value id

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

\An —

array of rules to run against the User-Agent or NULL if no rules are found

_findRulesByProperties()

_findRulesByProperties(string  $userAgent, array  $props2Vals) : \An

Try and find User-Agent type and thus the rules to run by using the properties returned from the tree walk. All the properties defined in the property matcher set must match. If a match is found then the rules can be returned.

Parameters

string $userAgent

The User-Agent to find properties for

array $props2Vals

The results of the tree walk, map of property id to value id

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

\An —

array of rules to run against the User-Agent or NULL if no rules are found

_checkPropertiesMatch()

_checkPropertiesMatch(array  $propList, array  $props2Vals) : TRUE

This functions checks all the properties in the property matcher branch of this rule group. This branch contains a list of properties and their values.

All must match for this function to return true.

In reality the properties and values are indexes to the main property and value arrays.

Parameters

array $propList

The list of properties to check for matches

array $props2Vals

The results of the tree walk, map of property id to value id

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

TRUE —

if ALL properties match, false otherwise

_findRulesToRunByRegex()

_findRulesToRunByRegex(string  $userAgent, array  $ruleSet, string  $type) : \An

Loop over a set of refining rules to try and determine the User-Agent type and so find the rules to run on it.

Parameters

string $userAgent

The User-Agent to find properties for

array $ruleSet

The ruleset that contains the search regex id, refine regex id and the magical rulesToRun

string $type

The type of rule to run either Refine or Search

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

\An —

array of rules to run against the User-Agent or NULL if no rules are found

_findRulesByRegex()

_findRulesByRegex(string  $userAgent) : \An

Search for the rules to run by checking the User-Agent with a regex. If there is a match the rule list is returned.

Parameters

string $userAgent

The User-Agent to find properties for

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

\An —

array of rules to run against the User-Agent or NULL if no rules are found

_initProcessRegexes()

_initProcessRegexes() 

Process the regexes by overriding any default ones with API specific regexes.

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

_extractProperties()

_extractProperties(array  $rulesToRun, string  $userAgent, array  $sought) 

This function loops over all the rules in rulesToRun and returns any properties that match. The properties returned can be typed or strings.

Parameters

array $rulesToRun

The rules to run against the User-Agent to find the properties

string $userAgent

The User-Agent to find properties for

array $sought

A set of properties to return values for

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275