UA_RULES
UA_RULES = 'uar'
This class is used by the main API class and should not be used directly.
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.
integer | $propertyId | The ID of the property that is sought |
if the propertyId is used, FALSE otherwise
putProperties(string $userAgent, array $props2Vals, array $sought)
Merge the tree walk properties with the User-Agent string properties using the User-Agent rules
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 |
_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.
array | $group | The rule group that can contain a property matcher |
_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.
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 of rules to run against the User-Agent or NULL if no rules are found
_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.
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 of rules to run against the User-Agent or NULL if no rules are found
_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.
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 |
if ALL properties match, false otherwise
_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.
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 |
array of rules to run against the User-Agent or NULL if no rules are found
_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.
string | $userAgent | The User-Agent to find properties for |
array of rules to run against the User-Agent or NULL if no rules are found
_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.
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 |