Constants

CP_RULES

CP_RULES = 'cpr'

Properties

$treeProvider

$treeProvider : 

Type

$branch

$branch : 

Type

$propMatcherIdsInUse

$propMatcherIdsInUse : 

Type

$rulePropIdsInUse

$rulePropIdsInUse : 

Type

Methods

__construct()

__construct(  $tree) 

Parameters

$tree

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

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.

Returns

\The —

list of required properties.

putProperties()

putProperties(string  $clientSide) 

Merge the tree walk properties with the client side properties and run any additional rules based on the client side and tree walk properties. The rules can define replacement or additional values for properties and can also provide a new User-Agent to be used for a second tree walk. This is typically a fake User-Agent mapped to a device that cannot normally be detected such as the various iPhone models.

Parameters

string $clientSide

_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 rules to work correctly

Parameters

array $group

The rule group that can contain a property matcher

_initRuleSets()

_initRuleSets(array  $group) : \A

Prepare the rule set by extracting it from the current group and wrapping it in an array. This is done to remain compatible with initGetRulePropertyIds()

Parameters

array $group

The current parent group.

Returns

\A —

list of all rule sets

_init()

_init() 

Initiliase some data structures to avoid doing it during requests

_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

_parseClientSideProperties()

_parseClientSideProperties(  $clientSide) : \{key:

Parse the client side properties string into Map {key: value,} Sets to the tree.properties and returns the properties as Map (it is needed)

The clientSide is of the form: bjs.webGl:1|bjs.geoLocation:1|sdeviceAspectRatio:16/10|iusableDisplayHeight:1050 Each key:val part of clientSide is checked for sanity, if it looks not fine then that key:val will be ignored.

The first character of the property name is the type of the value.

Parameters

$clientSide

Returns

\{key: —

value,}

_getRulesToRun()

_getRulesToRun() 

_checkPropertiesMatch()

_checkPropertiesMatch(  $propertyMatchers) 

This functions checks all the properties in the property matcher branch of this rule group. This branch contains a list of properties, their values and an operator to use for comparison. 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

$propertyMatchers

_compareValues()

_compareValues(string  $detectedValue, string  $expectedValue, string  $operator,   $propTypeName) : boolean

Compare two values that can be one of String, Boolean or Integer using the passed in operator.

Parameters

string $detectedValue
string $expectedValue
string $operator
$propTypeName

Returns

boolean