\DeviceAtlas\DeviceTokenTrieWalker

Walks a provided identifier to try and find one or more matching components.

Summary

Methods
Properties
Constants
__construct()
seekComponents()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
findNextCharactersMatch()
hasTokenStartNode()
getTokenStartNode()
getDirectChildNode()
hasMatchCandidates()
getMatchCandidates()
isSwAllowedAnyMatch()
addMatchCandidates()
$rootNode
$delimitersHandler
$deviceData
$isLowerCaseData
N/A

Properties

$rootNode

$rootNode : 

Type

$delimitersHandler

$delimitersHandler : 

Type

$deviceData

$deviceData : 

Type

$isLowerCaseData

$isLowerCaseData : 

Type

Methods

__construct()

__construct(  $deviceData) 

Parameters

$deviceData
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

seekComponents()

seekComponents(  $identifier) 

Loop over the input string character by character and descend down a Trie structure to find matching Components.

The Trie is a shallow Trie created from token values. It expects either a full match to a token from an incoming identifier or a partial stats-with match if permitted by a found MatchCandidate.

Although the individual characters(*) are used to walk the Trie it is easier to think of the input string as a collection of tokens delimited by characters like spaces, semi-colons etc.

A given branch of the Trie may either be formed from a single token or formed from a chain of adjacent tokens.

At the end of a token, a matching Node may contain some MatchCandidates. These MatchCandidates contain a Component and some additional criteria that must be passed before the Component is added to the "found" collection.

(* in practice the codePoint is used to walk the trie and not the actual character itself)

Note1: See flow diagram in internal-docs/tokentriewalk.drawio.png

NOTE2: Some attempts were made to split the below method into multiple methods to add readability. The overall API performance dropped by around 40-50,000 detections per second with this change so it was reverted.

Parameters

$identifier

string The identifier to find matching components from.

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

findNextCharactersMatch()

findNextCharactersMatch(  $node,   $identifier,   $character,   $identifierCurrentPosition) 

The identifier can contain more than one character in the Node, so this function tries to find a match, if found, the character matched is returned along with the additional character position.

Parameters

$node
$identifier
$character
$identifierCurrentPosition
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

hasTokenStartNode()

hasTokenStartNode(  $node) 

Parameters

$node
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

getTokenStartNode()

getTokenStartNode(  $node) 

Parameters

$node
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

getDirectChildNode()

getDirectChildNode(  $node) 

Parameters

$node
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

hasMatchCandidates()

hasMatchCandidates(  $node) 

Parameters

$node
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

getMatchCandidates()

getMatchCandidates(  $node) 

Parameters

$node
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

isSwAllowedAnyMatch()

isSwAllowedAnyMatch(  $node) 

Parameters

$node
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

addMatchCandidates()

addMatchCandidates(  $matchResult,   $candidates,   $endTokenCharPosition,   $tokenPosition,   $atEndOfToken) 

Check if any of the match candidates pass the checks and add to cFound if so

Parameters

$matchResult

IdentifierMatchResult The collection to add found components to

$candidates

array The possible candidates to add to cFound

$endTokenCharPosition

int

$tokenPosition

int The current token position from the identifier

$atEndOfToken

boolean True if the Trie walk used the full token from the identifier. False otherwise.

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