UA_RULES
UA_RULES = 'uar'
This class is used by the main API class and should not be used directly.
__construct( $tree)
$tree |
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
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 1275list of required properties.
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 |
_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.
array | $group | The current parent group. |
A list of all rule sets
_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(array $sets)
Find all the properties that are used in the final rules. This is needed to optimise the Api.getProperty() function.
array | $sets | The rule set from the main rule group |
_skipUaRules( $props2Vals) : TRUE
Check list of items that skip rules - these are typically non-mobile boolean properties such as isBrowser, isBot, isCrawler etc
$props2Vals |
if the UA rules are to be skipped, FALSE if they are to be run
_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
_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(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 |